You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility
When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
Hello everyone! I hope you are staying safe. I am trying to complete the python coin flip challange, but I am stuck. I have written the following code so far.
import random
coin_toss = random.randint(1,2)
guess = input('Heads or Tails: ')
chance = 0
while chance < 5:
if coin_toss == 1 and guess == coin_toss:
print(‘You Won!’)
elif coin_toss == 2 and guess == coin_toss:
print(‘You Won!’)
elif coin_toss ==1 and guess != coin_toss:
print(‘Try Again’)
chance += 1
elif coin_toss == 2 and guess != coin_toss:
print(‘Try Again’)
chance += 1
else:
print (‘Error’)
if not chance <5:
print(‘You Loose!’)