Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game = input().split(' ')
- command = input()
- counter = 0
- while command != "end":
- indexes = command.split(' ')
- indexes.sort()
- index1 = int(indexes[0])
- index2 = int(indexes[1])
- counter += 1
- if 0 <= index1 < len(game) and 0 <= index2 < len(game) and index1 != index2:
- if game[index1] == game[index2]:
- print(f"Congrats! You have found matching elements - {game[index1]}!")
- game.pop(index2)
- game.pop(index1)
- if len(game) == 0:
- print(f"You have won in {counter} turns!")
- exit(0)
- else:
- print("Try again!")
- else:
- print("Invalid input! Adding additional elements to the board")
- game.insert(len(game) // 2, f"-{str(counter)}a")
- game.insert(len(game) // 2, f"-{str(counter)}a")
- command = input()
- print(f"Sorry you lose :(\n{' '.join(game)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement