2026fa_cse160/homework/homework04/strings/stringToCharacters02.py

15 lines
No EOL
354 B
Python

import string
message = '''
This program prints the Ascii codes for all the letters
in a text string entered by the user.
'''
print(message)
stringOfLetters = input("Enter a name or phrase: ")
# Note: The ord() function returns the integer code for a character.
for myCharacter in stringOfLetters:
print(f"{myCharacter:2s}{ord(myCharacter):3d}")