Advertisement
bl00dt3ars

3 Cards (Ivaylo Ivanov)

Jul 13th, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. cards = input().split(":")
  2. new_deck = []
  3. token = input()
  4.  
  5. while not token == "Ready":
  6.  
  7.     token = token.split(" ")
  8.     command = token[0]
  9.  
  10.     if command == "Add":
  11.         current_card = token[1]
  12.         if current_card in cards:
  13.             new_deck.append(current_card)
  14.         else:
  15.             print("Card not found.")
  16.  
  17.     elif command == "Insert":
  18.         current_card = token[1]
  19.         index = int(token[2])
  20.         if current_card in cards:
  21.             if 0 <= index < len(new_deck):
  22.                 new_deck.insert(index, current_card)
  23.         else:
  24.             print("Error!")
  25.  
  26.     elif command == "Remove":
  27.         current_card = token[1]
  28.         if current_card in new_deck:
  29.             new_deck.remove(current_card)
  30.         else:
  31.             print("Card not found.")
  32.  
  33.     elif command == "Swap":
  34.         first_card = token[1]
  35.         second_card = token[2]
  36.         a, b = new_deck.index(first_card), new_deck.index(second_card)
  37.         new_deck[a], new_deck[b] = new_deck[b], new_deck[a]
  38.  
  39.     elif "Shuffle" in command:
  40.         new_deck = new_deck[::-1]
  41.  
  42.     token = input()
  43.  
  44. print(" ".join(new_deck))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement