Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. string = input().split("|")
  2. command = input()
  3. odd = []
  4. even = []
  5. if_odd = True
  6. if_even = True
  7.  
  8. while command != 'Done':
  9. if 'Left' in command:
  10. tokens = command.split()
  11. move = int(tokens[2])
  12. if move > len(string):
  13. pass
  14. elif move == 0:
  15. pass
  16. else:
  17. string[move], string[move - 1] = string[move - 1], string[move]
  18. elif 'Right' in command:
  19. tokens = command.split()
  20. move = int(tokens[2])
  21. if move >= len(string):
  22. pass
  23. else:
  24. string[move], string[move + 1] = string[move + 1], string[move]
  25.  
  26. elif 'Odd' in command:
  27. for i, x in enumerate(string):
  28. if i % 2 != 0:
  29. odd.append(x)
  30. elif 'Odd' not in command:
  31. if_odd = False
  32. elif 'Even' in command:
  33. for i, x in enumerate(string):
  34. if i % 2 == 0:
  35. even.append(x)
  36. elif 'Even' not in command:
  37. if_even = False
  38. command = input()
  39.  
  40. if if_odd:
  41. print(' '.join(odd))
  42. if if_even:
  43. print(' '.join(even))
  44.  
  45. final = ''.join(string)
  46. print(f'You crafted {final}!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement