Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peopleMeals = {}
- unliked = 0
- line = input()
- while line != "Stop":
- tokens = line.split("-")
- if tokens[0] == "Like":
- guest = tokens[1]
- meal = tokens[2]
- if guest not in peopleMeals:
- peopleMeals[guest] = []
- if meal not in peopleMeals[guest]:
- peopleMeals[guest].append(meal)
- if tokens[0] == "Unlike":
- guest = tokens[1]
- meal = tokens[2]
- if guest not in peopleMeals:
- print(f"{guest} is not at the party.")
- elif meal not in peopleMeals[guest]:
- print(f"{guest} doesn't have the {meal} in his/her collection.")
- elif meal in peopleMeals[guest]:
- unliked += 1
- print(f"{guest} doesn't like the {meal}.")
- peopleMeals[guest].remove(meal)
- line = input()
- for k, v in sorted(peopleMeals.items(), key=lambda x: (-len(x[1]), x[0])):
- print(f"{k}: {', '.join(v)}")
- print(f"Unliked meals: {unliked}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement