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

31 lines
931 B
Python

import string
message = '''
This program prints the Ascii codes for the whitespace.
characters. These characters include the space, line return, tabs, etc.
Printing the whitespace string does not appear to generate any results.
Printing each character code is informative.
'''
message2 = '''
Open a web browser. Go to https://www.ascii-code.com.
Look up each of the codes from this program to determine
their purpose.
For example: 32 = space
Look up the rest of the whitespace codes.
'''
print(message)
print(f"string.whitespace = {string.whitespace}")
print(f"length of string.whitespace = {len(string.whitespace)}")
# Since you cannot easily see the effect of whitespace characters,
# we can print their numeric codes.
# Convert the string to a list of letters in the string.
whiteSpaceCharactersList = list(string.whitespace)
for myCharacter in whiteSpaceCharactersList:
print(f"{ord(myCharacter)}")
print(message2)