''' Purpose: produce and print the reverse of a user-supplied word (using accummulation) ''' ### get word reply = input( "Enter word: " ) word = reply.strip() #Just as a reminder, .strip() clears all leading and trailing whitespace from a string! ### get a copy of the word through accumulation #Accumulation is an important concept in 1112! We ant to build up an answer. #INITIALIZE an accumulator -- important vocab for the future and for the test! reverse = "" #Initialize reverse to an empty string #Why do we initialize it as an empty string? Because we eant to add to it to build up an answer! #We want to add more character to thei empty string until we get out final string answer. #ACCUMULATION IS INITIALIZED OUTSIDE THE FOR LOOP BEFORE THE FOR LOOP!!!!!!! for ch in word : #ch is arbitrary-- could be anything but make it DESCRIPTIVE and relevant to the task/its function #reverse = ch + reverse -- Wrong!! print("ch =" , ch) reverse = ch + reverse #Order matters! #What we're doing now is we're taking each character in the original sequence #and adding it to the front so apple becomes alppa because it'll add the a then the p #in front of that a then the p after that and so on and so on. print(reverse) ### print reverse print( reverse ) #This is a veriable #again, the purpose of accumulators is using an empty sting "" and then keep adding to it. #by saying accumulator = accumulator + (whateverIwaant) through string concatentation #that way it keeps getting that previous value of accumulator and adding the new string(s) ''' Class questions: Strip will take out the extra space: _______victoria_____ (with _ being blank space), strip will take out all of the space. '''