daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Aug 13th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top