Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TreasureChest:
- # your code goes here
- def __init__(self, item):
- self.item = item
- self.is_open = False
- def print_description(self):
- if self.is_open:
- print(self.item)
- else:
- print("a locked treasure chest")
- def open(self):
- self.is_open = True
- # your code goes here
- p = TreasureChest("a book of immense Python knowledge")
- q = TreasureChest("the guardian of group work")
- p.print_description()
- p.open()
- p.print_description()
- print("")
- q.print_description()
- q.open()
- q.print_description()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement