''' Purpose: expand input processing capabilities by splitting an input string into its component words ''' # get input reply = input( 'What are your three favorite words: ' ) print() # determine individual words w1, w2, and w3 # Think about how you can use the below statement in break_the_bank! # You have four things! w1, w2, w3 = reply.split() # This is multiple assignment # You are assigning three variables at once to three different things # since reply.split() produces a list of three different things # (or however many words you entered split up) # w1, w2, w3, w4 = reply.split() - now type in four words as input and you # can have four words :) # If reply is "I love pizza", reply.split() produces a list of words # separated by spaces ["I", "love", "pizza"] # Each word w1, w2, w3 is assigned to a word in the list produced by reply.split() # w1 is "I" w2 is "love" w3 is "pizza" # .split() is a function applied to a SINGLE string. # .split() is called on a string so reply is a string right? # reply.split() will take that string and break it up into # different pieces based on spaces (by default) # reply.split() will split the string into a list of words based on # where there were spaces (whitespace) in the original string and # hand you back a list # of words in the string. # The reason why I said by default in line 18 was because .split() # can take in a parameter and separate it based on something else too :) # More on that later! For now, we separate the string by spaces! # display results print( w1 ) print( w2 ) print( w3 ) # You can probably do any number of things however way you want # and we've either not covered it YET or # not shown certain specific examples ; we recommend you just # do things the way we taught it and experiment different ways to switch # it up on your own on Pycharm and if you run into problems let us know # or post on piazza outside class.