+ 3
Can someone please explain to me why my code result is error..
secret_number = 6 guess_count = 0 guess_limit = 3 while guess_count < guess_limit: guess = int(input ( 'Guess: ')) guess_count += 1 if guess == secret_number: print('You Won!!!')
21 Answers
+ 11
I think your Indentation might be the error in that
And to add upon that is how you take in input from users
+ 4
#You are program has Many Indentation errors.
"""secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
>guess = int(input ( 'Guess: '))
>guess_count += 1
>>>>>if guess == secret_number:
print('You Won!!!')<<"""
secret_number = 6
guess_count = 0
guess_limit = 3
#while guess_count < guess_limit:
#Sorry soloLearn does not support taking user input repeatedly
#Means in soloLearn While loop is useless with inputs
#But yeah It will surely work well in computer 💻
#Just copy my code from here and then Download A IDE like Pycharm, And then Have Fun with your game but yeah don't forget to remove the hash from the while function
guess = int(input ( 'Guess: '))
guess_count += 1
if guess == secret_number:
print('You Won!!!')
else:
print ("You lost")
#Yours Problem Solved
+ 2
(Error occurs from empty or unfilled input )
#No error in any case 😉
secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess_count += 1
try:
guess = int(input('Guess-'+str(guess_count)+': '))
if guess == secret_number:
print('You Won!!! (^-^)')
else:
print('You lost!! (×-×)')
except:
print('empty or not number guess (???)')
https://code.sololearn.com/cIeIFtWiCzQs/?ref=app
+ 1
MAnny
You have to enter 3 value at once as while 0 < 3:
Sololearn supports all input at once means you cannot take input one by one.
+ 1
A͢J I still don't understand where the problem is coming from, the code are correct
+ 1
Charles Jones ... check is out and see the result
+ 1
Charles Jones it says the error is at line 7
+ 1
Charles Jones I figured it out. Sololearn is the one giving me an error so I tried to use pydriod 3 to run the code and my result came out
+ 1
MAnny
As I said Sololearn support all input at once with separate lines so you have to take input like this:
20
40
50
Then press enter
+ 1
secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input ( 'Guess: '))
if guess == secret_number:
print('You Won!!!')
break
else:
guess_count += 1
This code should solve it and be easier to follow. Also, sololearn takes all inputs at once for some reason. For example, your inputs would be
1
2
3
If you would like to avoid this, I'd recommend replit or Visual Studio Code which are both free for your playground needs.
+ 1
Can someone explain to me what is error in my code
total = 0
x=0
while x<5:
age =int(input())
if age >3:
total+=100
x+=1
print ("total" )
+ 1
secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input ( 'Guess: '))
guess_count += 1
if guess == secret_number:
print('You Won!!!\n')
else:
print("Not Lucky!, Try again")
# Indentation Error
+ 1
secret_number = 6
guess_count = 0
guess_limit = 2
guess=int(input("Guess: "))
while guess_count < guess_limit:
guess=int(input("Guess: "))
guess_count += 1
if guess == secret_number:
print('You Won!!!')
break
else :
print ("You Loss")
0
What seems to be the error?
0
MAnny Im guessing it may be an indentation error. Could you copy the error text for me
0
When I gave it a go on sololearn it worked, so that's odd
0
After input you should write "if" to check your input and compare it with secret number
Can someone please explain to me why my code result is error..
secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input ( 'Guess: '))
if guess==secret_number:
print("you won")
break
else:
guess_count += 1
print("you lost")
0
ORWAH MOHAMMED ABDALRASOL if this code is for the ticket problem then you need to make x= 1 rather than 0 as if x=0 and the while loop is x< 5 then the code will require 6 inputs 0,1,2,3,4 and 5, or you could just make the while loop x<4 (And as stated above the code requires all inputs at the same time so will give an error when sololearn trys to add only 5 inputs)
In additon to this you need to chnage your last line too, you are printing the the string “total”, if you want to print the function then the line must be print(total).
Hope this helps
0
secret_number = 6
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input ( 'Guess: '))
guess_count += 1
if guess == secret_number:
print('You Won!!!')
0
Indentation was incorrect