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