Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. cards = input().split(':')
  2. result = []
  3. command = input()
  4.  
  5. while command != 'Ready':
  6. tokens = command.split()
  7. if tokens[0] == 'Add':
  8. card = tokens[1]
  9. if card not in cards:
  10. print("Card not found.")
  11. else:
  12. result.append(card)
  13.  
  14. elif tokens[0] == 'Insert':
  15. index = int(tokens[2])
  16. if not 0 <= index < len(cards) or tokens[1] not in cards:
  17. print("Error!")
  18. else:
  19. result.insert(index, tokens[1])
  20.  
  21. elif tokens[0] == 'Remove':
  22. if tokens[1] not in result:
  23. print("Card not found.")
  24. else:
  25. result.remove(tokens[1])
  26.  
  27. elif tokens[0] == 'Swap':
  28. x = tokens[1]
  29. y = tokens[2]
  30. index_1 = result.index(x)
  31. index_2 = result.index(y)
  32. result[index_1], result[index_2] = result[index_2], result[index_1]
  33.  
  34. elif tokens[0] == 'Shuffle':
  35. result.reverse()
  36.  
  37. command = input()
  38.  
  39. print(' '.join(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement