print('EXAMPLES FOR: chr(int) and ord(str) - also for "for", "in", to form an easy basic loop, and an intro to lists') print("Every visible letter, number, and symbol has a numeric code, for example, 80 is the code for "+chr(80)) print('Lets put some character codes in a list and then pull them out to "decode" what they mean') Lst_python=[80,121,116,104,111,110] #this is a list - a collection of items with one name enclosed in square brackets #this happens to be a list of integers but each element can be any type of variable print('First, here is our list' + str(Lst_python)) #we have to use "str" to convert the number in Lst_python to strings #we will use the "for" command to establish a loop and tell Python that "for" every one of the numbers in our list we want a letter print("Here are the letters these unicode numbers represent") for i in Lst_python: #note the colon at the end of the for statement - now we have to indent what we do in the loop print(chr(i)) #inside this loop Python "enumerates" a list of the elements in the list and uses each one sequentially #we can do basically the same thing to make a word from the list Str_myWord = "" # first we establish a string variable for i in Lst_python: Str_myWord+= chr(i) # now we just append the letters to the variable we created one at a time as we decode them print(Str_myWord) #and there it is print("Now lets add and exclamation mark and reconvert it to a series of integers") Str_myWord +="!" #the "+=" is a fast way to tell Python we want the accumulate the variable print(Str_myWord) Lst_newlist = [] # we create the "container" for our values for x in Str_myWord: #once again we do a simple loop though the letters in Str_myWord Lst_newlist.append(ord(x)) #ord will get the unicode value of the letter and appends that value as the next item in the list print (Lst_newlist)