-3

How would one write a code to display the conversion of individual letters in a string to it's ASCII equivalent? One example of the output in shell would look like this:

Enter a 3-letter word: Hey H = 72 e = 101 y = 121 
2
  • 3
    Does this answer your question? How to get the ASCII value of a character Commented Feb 5, 2020 at 19:02
  • You can use ord to get ascii equivalent of the character. And chr to convert ascii value to character. Commented Feb 5, 2020 at 19:02

2 Answers 2

0

Use built-in ord function

>>> ord('H') 72 
Sign up to request clarification or add additional context in comments.

Comments

0

Get the input, and print each character plus its ordinal value.

user_input = input("Enter a 3-letter word: ") for character in user_input: print(character + " = " + ord(character)) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.