0

Can anyone please explain why this code isn't working.

My code on here isn't working but the exact code copied to actual Python on my computer works. Here's the code: https://code.sololearn.com/c36UvpVTEWxp/?ref=app

16th Apr 2017, 8:37 AM
Ontleybot
Ontleybot - avatar
7 Answers
+ 9
<< Limitation of code playground input: you must to fill ALL the entries your app will require from the user before executing ( distant, not local ), so "real time" interactivity isn't possible ^^ >> https://www.sololearn.com/Discuss/183322/?ref=app https://www.sololearn.com/Discuss/205568/?ref=app
16th Apr 2017, 9:10 AM
visph
visph - avatar
+ 6
@visph is right real time interactivity is impossible here try using interpreters. The code should be like this import random numGuess = 0 origGuess = random.randint(0, 100) rndNum = random.randint(0, 100) if origGuess == rndNum: print('You got it!') print('The number was:, rndNum') print('It took you', numGuess,'tries') while True: origGuess = int(input('Guess a number between 0 and 100:')) #Guess too high if origGuess > rndNum: print('Too high!') origGuess = int(input('Guess a number between 0 and 100:')) numGuess += 1 #Guess too low elif origGuess < rndNum: print('Too low!') origGuess = int(input('Guess a number between 0 and 100:')) numGuess += 1 #Guess right else: print('You got it!') print('The number was:, rndNum') print('It took you', numGuess,'tries')
16th Apr 2017, 9:16 AM
MrCoder
MrCoder - avatar
+ 5
origGuess was used in the if statement even thou you didn't define it yet, try defining it first then use it
16th Apr 2017, 9:13 AM
MrCoder
MrCoder - avatar
+ 5
@Ontleybot Hmm, let me take a look again
16th Apr 2017, 9:15 AM
MrCoder
MrCoder - avatar
+ 3
Maybe that could work @MrCoder
16th Apr 2017, 9:13 AM
Ontleybot
Ontleybot - avatar
+ 3
@MrCoder nope, don't work
16th Apr 2017, 9:14 AM
Ontleybot
Ontleybot - avatar
+ 2
well that's kinda stupid
16th Apr 2017, 9:11 AM
Ontleybot
Ontleybot - avatar