I am trying to create a Coin Flip Game this is what I have came up with so far:
import random
def headsOrTails(number_of_flips):
number_of_flips = int(input("How many times do you want to flip the coin: "))
heards_count = 0
tails_count = 0
for i in range(number_of_flips):
rand = random.randint(1, 2)
if rand == 1:
heards_count += 1
print(f"It is Heads.\n Heads {heards_count}")
elif rand == 2:
tails_count += 1
print(f"It is Tails.\n Tails {tails_count}")
print(heards_count)
print(tails_count)
headsOrTails(1)
I want to tell the user that they are very lucky if they get heard or tail 6 times in a role. And I was wondering if anyone can help me do that.
An if statement like this should work:
heards_countcan only equal 6 if you pass in six to the function headsOrTails(). Get rid of the linerandwill be reset on each iteration of the loop so it does not check if rand has been equal to 1 four times. Hope this helps!