Dec-22-2019, 07:52 PM
I made a cleaned up version of your code:
I also took out the unnecessary int() calls for attempts, and changed it so that there is only one int() call for guess.
attempts=0 guess=0 number=random.randint(1,100) while guess!=number: if attempts<1: guess=input('Feeling lucky? Take a guess!\n') attempts+=1 elif guess>number: guess=input('Too high! Would you like to try again?\nEnter a number = Yes Alt + F4 = No\n') attempts+=1 elif guess<number: guess=input('Try a bit higher! Would you like to try again?\nEnter a number = Yes Alt + F4 = No\n') attempts+=1 guess = int(guess) else: if attempts<5: print('Congratulations! That only took you '+str(attempts)+' attempts - pretty impressive!') elif int(attempts)<10: print('It took you '+str(attempts)+' tries, but you got there eventually!') else: print('Gosh! '+str(attempts)+' guesses?! It\'s not your lucky day.') print(input('How long did you spend trying?\n')+'? Lol')By limiting it to one statement per line, the structure of your code becomes much clearer. It makes it easier for people to help you, and that makes it more likely that they will.
I also took out the unnecessary int() calls for attempts, and changed it so that there is only one int() call for guess.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures