I wrote a code for throwing a coin, but when the player decides on the key, the function returns the variable before it is assigned a value. I do not know why and how to fix it. Here is the code itself:

import random player1_name = input("Имя: ") player1_bet = input("Орел/Решка?: ") player2_name = input("Имя: ") def coin_sides(): if player1_bet.lower == "решка": player2_bet = "орел" elif player1_bet.lower() == "орел": player2_bet = "решка" else: print("Invalid inputs, please try again.") return player2_bet def flip_coin(): player2_bet = coin_sides() flipped_side = random.randint(1, 2) if flipped_side == 1: print(player1_bet.capitalize() + "! " + player1_name + " выходит победителем!") elif flipped_side == 2: print(player2_bet.capitalize() + "! " + player2_name + " выходит победителем!") coin_sides() flip_coin() 
  • if player1_bet.lower () == "tails": forgot to put the brackets - S. Nick

0