Added Homework 04 - Strings
This commit is contained in:
parent
aad4e226c5
commit
be356ccb59
24 changed files with 315 additions and 0 deletions
15
homework/homework04/strings/stringToCharacters02.py
Normal file
15
homework/homework04/strings/stringToCharacters02.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
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}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue