''' Purpose: demonstrate the printing of a string of characters ''' # get a string of three letters reply = input( "Enter a three letter-string: " ) ### print the characters first_character = reply[0] second_character = reply[1] third_character = reply[2] print( first_character ) print( second_character ) print( third_character ) # If you have reply as 'abc' and do reply[0] + reply[1] + reply[2] # that will concatenate the three strings so you'll # have abc printed not # a # b # c # get a string reply = input( "Enter a string: " ) ### print the characters for c in reply: print( c ) print('How is Cam doing today?') # IMPORTANT: the loop variable changes value each iteration # in the loop. # If reply is 'computer' # the first time, c is 'c' then next time it's 'o' then next time # it's 'm' etc. all the way until we reach the end of a string. # for loops # Everything indented into the for loop (loop body) # it will repeat those statements each iteration of the loop # aka each time we have a new loop variable value! print('All done! :D') result = '' # empty string for c in reply: result = c + result print(result) # soooo we see how we start off with an empty string # and build up the value of result by adding the new # character to the front of the current value of result each time # Again, the loop value changes value each time to the next thing # in your sequence. # If you are running your loop like for c in string: # the loop variable will assume the value of each smaller # part of that string (it will be each character one at a time) #