#!/usr/bin/env python3
def calculate_pets_number(pets_dict):
pets_quantity = 0
for pet in pets_dict.keys():
pets_quantity = pets_quantity + pets[pet]
return pets_quantity
pets = {}
while True:
print("What kind of pet do you have?")
pet = input()
if pet == "rock":
break
if pet not in pets.keys():
pets[pet] = 1
print("You have a " + pet + " with a total of 1 " + pet + ", with a total of " + str(calculate_pets_number(pets)) + "pet(s).")
else:
pets[pet] = pets[pet] + 1
print("You have a " + pet + " with a total of " + str(pets[pet]) + " " + pet + "s, with a total of " + str(calculate_pets_number(pets)) + " pet(s).")
Comments
Leave a comment