# commalist.py # Walker M. White (wmw2) # August 30, 2015 """Module to show off how to "parse" a comma-separated list. This module only contains one function. You should study this function as you may find it helpful for Lab 2 (and therefore Assignment 1).""" def second_in_list(s): """Returns: second item in comma-separated list The final result does not have any whitespace on edges Parameter s: The list of items Precondition: s is a string of items separated by commas. """ startcomma = s.index(',') tail = s[startcomma+1:] endcomma = tail.index(',') item = tail[:endcomma].strip() # Correct version #item = tail[:endcomma] # Compare this one return item