Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cat:
- def __init__(self, name, color, legs):
- self.name = name
- self.color = color
- self.legs = legs
- def __str__(self):
- return u'Name: {}. Color: {}. Legs: {}'.format(self.name, self.color, self.legs)
- class Cats:
- cats = {}
- def __init__(self):
- pass
- def add(self, cat):
- self.cats[cat.name] = cat
- def get(self, name):
- return self.cats.get(name)
- cats = Cats()
- cats.add(Cat('felix', 'red', 4))
- cats.add(Cat('flux', 'blue', 4))
- cats.add(Cat('flask', 'green', 44))
- cats.add(Cat('flo', 'green', 13))
- cat = cats.get(raw_input("vvedite imya : "))
- if not cat:
- print('Cat not found')
- else:
- print(cat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement