I think the problem is one of scope. It looks like the other commenters are aware of this - as are you.
Let’s look at the logic of the organization below.
start_game() is called. It decides the number of rounds and keeps track of the score. It calls
run_round() which returns a
False result (i.e. win or lose). It then prints the results. In short, the function runs a round a prints the results.
Second, let’s look at
run_round(). It runs a single round of the game and returns the result. It calls
get_player_guess() which return the player guess,
flip_coin() which returns the coin flip, prints out the results of both, and then returns the result.
This type of logic is very common in programming. A single large task is broken down into logical parts. A single controller function calls child (or helper) functions which each do a part of the task. The controller function then returns the result(s) of the task.
I hope the code below illustrates this methodology.
COIN_SIDES = ("heads", "tails")
game_round = 3
rounds_won = 0
rounds_lost = 0
for round in range(game_round):
print("Starting round", count_round + 1, "of", game_round)
result = run_round()
if result == True:
rounds_won += 1
rounds_lost += 1
print("Rounds Won:", rounds_won, "\tRound Lost:", rounds_lost)
player_guess = get_player_guess()
actual_flip = flip_coin()
round_outcome = player_guess == actual_flip
print("You flipped:", player_guess)
print("You guessed:", actual_flip)
player_guess = input("Heads or Tails?: ").lower()
if player_guess not in COIN_SIDES:
print("\nHeads or Tails only!")