# Find the ASCII value of each character of the string in Python

Here, we will learn how to find the ASCII value of each character of the given string in Python programming language?
Submitted by Bipin Kumar, on December 06, 2019

A string will be given by the user and we have to write Python code that prints the ASCII value of each character of the string. ASCII stands for the American Standards Code for Information Interchange. It provides us the numerical value for the representation of characters. To solve this problem, we will use the range() function and ord() function. Here, we will use simple techniques to solve this problem. Before going to solve this problem, we will learn a little bit about the range() and ord() function.

Python range() function

The range() is a built-in function available in Python. In simple terms, the range allows them to generate a series of numbers within a given interval. This function only works with the integers i.e. whole numbers.

Python ord() function

The ord() function in Python accepts a string of length 1 as an argument and returns the ASCII value of the passed argument. For example, ord('a') returns the integer 97.

Program:

```# initialize a string
s='Motihari'
ascii_codes=[] # to contain ASCII codes

# getting ASCII values of each character
# using ord() method and appending them
# to "A"
for i in range(len(s)):
ascii_codes.append(ord(s[i]))

# printing the result
print('The ASCII value of each character are:',ascii_codes)
```

Output

```The ASCII value of each character are: [77, 111, 116, 105, 104, 97, 114, 105]
```