Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. ### December 2010 ###
  2.  
  3. ### Question 3 ###
  4.  
  5. class BadTypeException(AttributeError):
  6.  
  7. pass
  8.  
  9. def list_to_lower(str_list):
  10. """
  11. Return a new list of the elements in str_list after they have been
  12. turned to lowercase strings. str_list should be a list of strings, otherwise
  13. a BadTypeException is raised with the error message: 'Non-string object
  14. found.'
  15. """
  16.  
  17. new_str_list = []
  18.  
  19. for element in str_list:
  20. try:
  21. new_str_list.append(element.lower())
  22. except:
  23. raise BadTypeException, 'Non-string object found.'
  24.  
  25. return new_str_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement