Lesson 6: Head or tail?

Post date: Dec 7, 2018 3:59:03 PM

import random

print("Let's practice!")

wins = 0

losses = 0

for i in range(0,5):

coin = random.randint(0,1)

side = "Head"

if coin == 1:

side = "Tail"

guess = input("Head or Tail?").upper()

if side.upper() == guess:

print(side, "Ouch... :-( ... you won! ")

wins = wins + 1

else:

print(side, "Hurray... I won, you lost!!!")

losses = losses + 1

print("Wins:", wins, "Lost rounds:", losses)

if wins > losses:

print("Congrat! You won the game.")

elif wins == losses:

print("It's a tie!")

else:

print("Looser!!!")