Hi everyone. I am just learning Python on class so I am really at the basic. I need to write a python program that will flip a coin 100 times and then tell how many times tails and heads were flipped. This is what I have so far but I keep getting errors.
>>>import random
>>> coin_heads, coin_tails, coin_flips = 0,0,0
>>> while timesflipped <100:
... coin_flips = random.randrange(2)
... if coin_flips == 0:
... coin_heads = coin_heads + 1
... else:
... coin_tails = coin_tails + 1
... timesflipped += 1
...
>>> print "Out of 100 flips " + str(coin_heads) + " were heads and " + str(coin_tails) + " were tails."
Problem is it returns this to me:
Out of 100 flips 0 were heads and 100 were tails.
Also everything is indented I just couldn't get it to show up in the post.
Any help is much appreciated. Thank you