Advertisement
dbwonders

ps9_revised

Jun 2nd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. def __str__(self):
  2.         """
  3.        Return the string representation for a set, which consists of
  4.        the string representation of each shape, categorized by type
  5.        (circles, then squares, then triangles)
  6.        """
  7.         templist = []
  8.         shapeslist = self.shapes
  9.        
  10.         for shape in shapeslist:
  11.             templist.append(shape.__str__())
  12.         for string in templist:
  13.             splitstring = string.split()
  14.         # in order to replicate handout results, I sorted by first word only.  
  15.         # def first(splitstring): return splitstring[0] same as key = lambda:
  16.         splitsorted = sorted(templist, key=lambda splitstring: splitstring[0])
  17.         print splitsorted  
  18.         return'\n'.join(splitsorted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement