Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def __str__(self):
- """
- Return the string representation for a set, which consists of
- the string representation of each shape, categorized by type
- (circles, then squares, then triangles)
- """
- templist = []
- shapeslist = self.shapes
- for shape in shapeslist:
- templist.append(shape.__str__())
- for string in templist:
- splitstring = string.split()
- # in order to replicate handout results, I sorted by first word only.
- # def first(splitstring): return splitstring[0] same as key = lambda:
- splitsorted = sorted(templist, key=lambda splitstring: splitstring[0])
- print splitsorted
- return'\n'.join(splitsorted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement