''' Purpose: do some functions produces lists from a string ''' def ints( ns ) : ''' Returns list of integers corresponding to the integer substrings in ns. ''' # can't use int( ns ) because not correctly formatted for a single int numeric_strings = ns.split() # gives us a list of numeric strings that were separated by space in ns result = [] # list of ints that's associated with the string ns # result can be our list accumulator # for each string in numeric strings for string in numeric_strings: # convert string into an int number = int( string ) # put the new number into the list accumulator result.append( number ) # now we have a list of ints instead of a list of numeric strings in our variable result return result def parse_phone_string( pn ) : ''' Returns a three-element integer list for string phone # pn: 1st element: pn area code 2nd element: pn prefix 3rd element: pn line number ''' pass