angelstoev

Untitled

Oct 21st, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. shoping_list = input().split("!")
  2.  
  3. while True:
  4.     command = input()
  5.     if command == 'Go Shopping!':
  6.         break
  7.     new_commands = command.split()
  8.     action = new_commands[0]
  9.     item_one = new_commands[1]
  10.     if action == 'Correct':
  11.         item_two = new_commands[2]
  12.         if item_one in shoping_list:
  13.             shoping_list = list(map(lambda x: x.replace(item_one, item_two), shoping_list))
  14.         else:
  15.             continue
  16.     elif action == 'Urgent':
  17.         if item_one not in shoping_list:
  18.             shoping_list.insert(item_one, 0)
  19.         else:
  20.             continue
  21.     elif action == 'Unnecessary':
  22.         if item_one in shoping_list:
  23.             shoping_list.remove(item_one)
  24.         else:
  25.             continue
  26.     elif action == 'Rearrange':
  27.         if item_one in shoping_list:
  28.             shoping_list.remove(item_one)
  29.             shoping_list.append(item_one)
  30. print(", ".join(shoping_list))
Add Comment
Please, Sign In to add comment