Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def play_round(cards, i_1, i_2, round_num):
- if i_1 == i_2 or i_1 not in range(len(cards)) or i_2 not in range(len(cards)):
- print(f"Invalid input! Adding additional elements to the board")
- card = f"-{round_num}a"
- middle = len(cards) // 2
- cards.insert(middle, card)
- cards.insert(middle + 1, card)
- return cards
- if cards[index_1] == cards[index_2]:
- element = cards[index_1]
- print(f"Congrats! You have found matching elements - {element}!")
- cards.remove(element)
- cards.remove(element)
- return cards
- print(f"Try again!")
- return cards
- memory_cards = input().split()
- command = input()
- counter = 0
- while not command == 'end':
- index_1, index_2 = list(map(int, command.split()))
- counter += 1
- memory_cards = play_round(memory_cards, index_1, index_2, counter)
- if len(memory_cards) == 0:
- print(f"You have won in {counter} turns!")
- break
- command = input()
- if len(memory_cards) > 0:
- print(f"Sorry you lose :(")
- print(' '.join(memory_cards))
Advertisement
Add Comment
Please, Sign In to add comment