''' Purpose: demonstrate string acquisition (the getting of input) ''' # get input # Introduction to input! reply = input( 'Tell me a favorite word: ' ) # We store what the user typed as input into the variable reply. # input( prompt ) hands back what the user typed as a string # If you assign the input( prompt ) to a variable (like reply), # whatever the user types is stored in reply! # input( prompt ) prints the prompt (which is a string) # You type the user input and hit enter! print() # compute length of word # len() is important!!! # len ( some string ) gives you the number of characters of that string. n = len( reply ) # The len() function finds the length of a sequence. # So I typed in "weird" and "weird" is stored in reply and the # the length of "weird" (the string) is 5 # characters! Characters aren't just letters. 'Happy birthday' # is 14 characters including the space (13 letters 1 space) # give feedback print( 'Did you know that', reply, 'has length', n ) # Prints strings and the variable values separated by spaces # since commas allow you to print different types (strings, numbers, etc.) # all on one line!