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
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
+ 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')
+ 5
origGuess was used in the if statement even thou you didn't define it yet, try defining it first then use it
+ 5
@Ontleybot Hmm, let me take a look again
+ 3
Maybe that could work @MrCoder
+ 3
@MrCoder nope, don't work
+ 2
well that's kinda stupid