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
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"))
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.
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.
Hi guy's, Thank you for your support!
You're welcome.
Join our real-time social learning platform and learn together with your friends!