Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numbers = input().split(" ")
- command = input()
- turns = 0
- while True:
- if command == "end":
- break
- turns += 1
- nums = command.split(" ")
- ind_one = int(nums[0])
- ind_two = int(nums[1])
- if ind_one != ind_two and 0 <= ind_one <= len(numbers) and 0 <= ind_two <= len(numbers):
- if numbers[ind_one] == numbers[ind_two]:
- print(f"Congrats! You have found matching elements - {numbers[ind_one]}!")
- x = numbers.pop(ind_one)
- numbers.remove(x)
- else:
- print("Try again!")
- else:
- print(f"Invalid input! Adding additional elements to the board")
- mid = len(numbers) // 2
- numbers.insert(mid, f"-{turns}a")
- numbers.insert(mid, f"-{turns}a")
- if len(numbers) == 0:
- break
- command = input()
- if len(numbers) > 0:
- print("Sorry you lose :(")
- for i in numbers:
- print(i, end=" ")
- else:
- print(f"You have won in {turns} turns!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement