Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. cards = input().split(":")
  2.  
  3. line = input().split()
  4.  
  5. while line[0] != "Ready":
  6.     command = line[0]
  7.  
  8.     if command == "Add":
  9.         card = line[1]
  10.  
  11.         if card in cards:
  12.             cards.remove(card)
  13.             cards.append(card)
  14.         else:
  15.             print("Card not found.")
  16.  
  17.     elif command == "Insert":
  18.         card = line[1]
  19.         index = int(line[2])
  20.         new_place = card
  21.  
  22.         if card in cards:
  23.             if index in range(len(cards)):
  24.                 cards.remove(card)
  25.                 cards.insert(index, new_place)
  26.         else:
  27.             print("Error!")
  28.  
  29.     elif command == "Remove":
  30.         card = line[1]
  31.  
  32.         if card in cards:
  33.             cards.remove(card)
  34.         else:
  35.             print("Card not found.")
  36.  
  37.     elif command == "Swap":
  38.         card_1 = line[1]
  39.         card_2 = line[2]
  40.         card_1_1 = cards.index(card_1)
  41.         card_2_2 = cards.index(card_2)
  42.  
  43.         cards[card_1_1], cards[card_2_2] = cards[card_2_2], cards[card_1_1]
  44.  
  45.     elif command == "Shuffle":
  46.         if line[1] == "deck":
  47.             cards.reverse()
  48.  
  49.     line = input().split()
  50.  
  51. print(" ".join(cards))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement