I am writing a heads or tails guessing program.
I am trying to figure out how to make the input that the user gives case insensitive and I've tried .upper()
and .lower()
and I'm just not sure how to do it.
import random
coin = ['Heads', 'Tails']
guess_count = 0
while guess_count <= 5:
flip = random.choice(coin)
guess = input("Guess Heads or Tails? ")
guess_count += 1
if guess_count == 5:
print("Out of attempts")
break
elif guess == 'Quit':
break
elif guess == flip:
print(f"It was {flip} good job!")
print(f"You got it in {guess_count} attempt(s).")
break
else:
if guess != flip:
print("Try again!")
print(f"Guess Count: {guess_count}")
print("Game Over!")