Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elements = input().split()
- moves = 0
- while True:
- command = input()
- if command == "end":
- break
- if len(elements) <= 0:
- print(f"You have won in {moves} turns!")
- break
- moves += 1
- command = command.split()
- first_index = int(command[0])
- second_index = int(command[1])
- if first_index == second_index or first_index > len(elements) or second_index > len(elements) \
- or int(first_index) < 0 or int(second_index) < 0:
- print("Invalid input! Adding additional elements to the board")
- middle_of_elements = len(elements) / 2
- frase = f"-{moves}a"
- elements.insert(int(middle_of_elements), frase)
- another_index = elements.index(frase)
- elements.insert(another_index + 1, frase)
- elif elements[first_index] == elements[second_index]:
- print(f"Congrats! You have found matching elements - {elements[first_index]}!")
- current_symbol = elements[first_index]
- elements.remove(current_symbol)
- elements.remove(current_symbol)
- elif elements[first_index] != elements[second_index]:
- print("Try again!")
- if len(elements) > 0:
- print("Sorry you lose :(")
- print((" ").join(elements))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement