GroZnik81

3та

Dec 13th, 2020
16
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lines = input()
  2. guests ={}
  3. dislike_list =[]
  4. while not lines =="Stop":
  5. command_data =lines.split("-")
  6. command = command_data[0]
  7. if command == "Like":
  8. guest =command_data[1]
  9. meal =command_data [2]
  10. if guest not in guests:
  11. guests[guest] = []
  12. if meal not in guests[guest]:
  13. guests[guest].append(meal)
  14.  
  15. elif command == "Unlike":
  16. guest = command_data[1]
  17. meal = command_data[2]
  18.  
  19. if guest not in guests:
  20. print(f"{guest} is not at the party.")
  21. else:
  22. if meal in guests[guest]:
  23. unlike_meal = guests[guest].pop()
  24. dislike_list.append(unlike_meal)
  25. print(f"{guest} doesn't like the {meal}.")
  26. else:
  27. print(f"{guest} doesn't have the {meal} in his/her collection.")
  28.  
  29.  
  30. lines = input()
  31.  
  32. sorted_guests = sorted(guests.items(),key=lambda x: (x[1],x[0]),reverse=True)
  33.  
  34. for key, value in sorted_guests:
  35. print(f"{key}: {', '.join(value)}")
  36.  
  37. print(f"Unliked meals: {len(dislike_list)}")
  38.  
RAW Paste Data