Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

count = 1 G=5 u = int(input("enter number")) for i in range(1,10): while count<=7: if count==1 and u==G: print ("Awesome!") break elif u==G: print(" you are correct") break elif u!=G: print("try again") count = count+1 I am not able to end the loop properly. I want user to guess the number for 7 times, if its correct exit or else ask for try if its less than 7

OpenStudy (anonymous):

I think if you just delete the 'for' loop, and after : elif u != G : print("try again") // Here ask the user to enter U again for example : u = int(input("enter number"))

OpenStudy (nethwa):

The problem is, that the user can guess only one time - because you just ask at the beginning, while initiating the variables. You just need to put a new query for a user input in the second elseif.

OpenStudy (anonymous):

maybe there's a problem with indentation of the statement count=count+1.In the code you hv written, it does not lie under the while loop and hence the loop won't be exited.

OpenStudy (anonymous):

Hi guy's, Thank you for your support!

OpenStudy (anonymous):

You're welcome.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!