Lesson 6: Loops - Head or Tail?

posted Dec 5, 2018, 8:03 AM by Attila Lengyel
for i in range(1,12):
print(i)

import random

wins = 0
losses = 0

for i in range(0,5):
flip = random.randint(0,1)
coin = "Head"
if flip == 0:
coin = "Tail"
answer = input("Head or Tail?:")

if answer == coin:
print("You won! It was", coin)
wins = wins + 1
else:
print("You Lost! It was", coin)
losses = losses + 1

print("You won", wins, "times")
print("You lost", losses, "times")

Comments