Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### December 2010 ###
- ### Question 3 ###
- class BadTypeException(AttributeError):
- pass
- def list_to_lower(str_list):
- """
- Return a new list of the elements in str_list after they have been
- turned to lowercase strings. str_list should be a list of strings, otherwise
- a BadTypeException is raised with the error message: 'Non-string object
- found.'
- """
- new_str_list = []
- for element in str_list:
- try:
- new_str_list.append(element.lower())
- except:
- raise BadTypeException, 'Non-string object found.'
- return new_str_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement