mardi 4 août 2015

Python ( Heads or Tails Counter )

I'm trying to create a simple heads or tails program. For some reason it's not working and I have no idea why. Any ideas?

import random


counter = 0
flip = random.randint(1,2) # Initializing Values of variables
heads_counter = 0
tails_counter = 0

if flip == 1:
    heads_counter +=1
    counter +=1

elif flip == 2:
     tails_counter +=1
     counter +=1

else:
    print("Invalid flip")


print("Flip is",flip)
print("Flipped The coin",counter,"Times")
print("Landed Heads",heads_counter,"Times")
print("Landed Tails",tails_counter,"Times")




Aucun commentaire:

Enregistrer un commentaire