+ 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!!!')

26th Jun 2022, 4:52 PM
MAnny
MAnny - avatar
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
27th Jun 2022, 10:08 AM
Sokkai
Sokkai - avatar
+ 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
27th Jun 2022, 11:20 AM
Hassaan
Hassaan - avatar
+ 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
28th Jun 2022, 5:08 AM
SAN
SAN - avatar
+ 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.
26th Jun 2022, 4:54 PM
A͢J
A͢J - avatar
+ 1
A͢J I still don't understand where the problem is coming from, the code are correct
26th Jun 2022, 4:57 PM
MAnny
MAnny - avatar
+ 1
Charles Jones ... check is out and see the result
26th Jun 2022, 4:59 PM
MAnny
MAnny - avatar
+ 1
Charles Jones it says the error is at line 7
26th Jun 2022, 5:01 PM
MAnny
MAnny - avatar
+ 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
26th Jun 2022, 5:21 PM
MAnny
MAnny - avatar
+ 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
26th Jun 2022, 5:54 PM
A͢J
A͢J - avatar
+ 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.
26th Jun 2022, 10:16 PM
Gwendal Cardenas Ortiz
+ 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" )
27th Jun 2022, 8:16 AM
ORWAH MOHAMMED ABDALRASOL
+ 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
27th Jun 2022, 10:02 AM
Faisal
Faisal - avatar
+ 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")
27th Jun 2022, 1:38 PM
Jithin v Jolly
Jithin v Jolly - avatar
0
What seems to be the error?
26th Jun 2022, 4:54 PM
Charles Jones
Charles Jones - avatar
0
MAnny Im guessing it may be an indentation error. Could you copy the error text for me
26th Jun 2022, 5:10 PM
Charles Jones
Charles Jones - avatar
0
When I gave it a go on sololearn it worked, so that's odd
26th Jun 2022, 5:27 PM
Charles Jones
Charles Jones - avatar
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")
27th Jun 2022, 8:41 AM
Hossein_Hejazi
Hossein_Hejazi - avatar
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
27th Jun 2022, 3:29 PM
Ben Rogers
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!!!')
28th Jun 2022, 2:40 AM
Neha Sharma
0
Indentation was incorrect
28th Jun 2022, 2:41 AM
Neha Sharma