Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number_plants = int(input())
- plant_dictionary = {}
- plant_rating = {}
- for plant in range(number_plants):
- plant_name, rarity = input().split("<->")
- plant_dictionary[plant_name] = int(rarity)
- while True:
- command = input().split(": ")
- if command[0] == "Exhibition":
- break
- plant = command[1].split(" - ")[0]
- if plant not in plant_dictionary:
- print("error")
- elif command[0] == "Rate":
- rating = command[1].split(" - ")[1]
- if plant not in plant_rating.keys():
- plant_rating[plant] = [int(rating)]
- else:
- plant_rating[plant].append(int(rating))
- elif command[0] == "Update":
- new_rarity = command[1].split(" - ")[1]
- plant_dictionary[plant] = int(new_rarity)
- elif command[0] == "Reset":
- plant_rating[plant] = []
- for key in plant_rating.keys():
- if len(plant_rating[key]) > 0:
- plant_rating[key] = [sum(plant_rating[key]) / len(plant_rating[key])]
- else:
- plant_rating[key] = [0]
- for key in plant_rating.keys():
- plant_rating[key] = [str(f"{i:.2f}") for i in plant_rating[key]]
- print("Plants for the exhibition:")
- for key in plant_dictionary.keys():
- if key not in plant_rating:
- plant_rating[key] = ["0.00"]
- print(f"- {key}; Rarity: {plant_dictionary[key]}; Rating: {''.join(plant_rating[key])}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement