''' Purpose: convert an input list of integers into an integer list ''' # get input reply = input( 'Enter integers: ' ) print() # split reply into list of numeric STRINGS nbr_strings = reply.split() # see what we got print( 'nbr_strings:', nbr_strings ) print() # convert NUMERIC text into list of numbers # IMPORTANT !! REVIEW THIS !! # LIST ACCUMULATOR # set up the accumulator to prepare for adding elements; we are building a list of numbers numbers = [] # list accumulation always start with an EMPTY LIST; denoted by brackets [] # process the strings of nbr_strings one-by-one # for each numeric string (ns) in our list of numeric strings # we want to cast each numeric string to its integer counterpart for ns in nbr_strings : # process the current numeric string # get numeric equivalent of ns nbr = int( ns ) # convert each ns into an int we call nbr print( nbr ) # add equivalent int to list of numbers # put nbr into our list accumulator, add to the end of the list # adding elements at the end of a list is called appending --> we use the function append( x ) # where x is something that you want to put at the end of your list # x can be anything like strings, ints, floats, even lists numbers.append( nbr ) # format: your_list.append( nbr ) --> we have put nbr to the end of our list called numbers # v = numbers.append( nbr ) # format: your_list.append( nbr ) --> we have put nbr to the end of our list called numbers # print( v ) # v here will be None because the append() function returns None # this is a GOTCHA!!!!!!! TAKE NOTE OF THIS PLZ # append() will change/update the ORIGINAL LIST !!!!! you don't need an assignment statement !!!!!!! # the function does not hand anything back, it gives you another keyword None # if you assign numbers = numbers.append( nbr ) IT WILL DESTROY THE LIST numbers --> numbers is now None and not a list # Lists are mutable = can be changed once built # strings are immutable!! cannot be changed once built # print the updated list of numbers print( 'numbers:', numbers )