0
This program always shows break outside the loop !
Suggest something to resolve this https://code.sololearn.com/c55O4DHU63oE/?ref=app
10 Respuestas
+ 6
Always use the same amount of indentation throughout your code, usually four spaces per indentation level.
This is error-prone and very hard to read and maintain:
while numberofguess<6:
if guess>numb:
print("your guess is more,try one more time ^_^"+guessleft+",guess left")
if guess<numb:
print("your guess is less,try one more time ^_^"+guessleft+",guess left")
break
if guess==numb:
print(...)
It should look something like this:
while numberofguess<6:
if guess>numb:
print(...)
elif guess<numb:
print(...)
break
elif guess==numb:
print(...)
+ 5
You need to fix your indentation. Everything that's supposed to belong to the while loop, has to be indented.
Also you should break after your win message, not before.
Try to read the error messages and find as many mistakes as you can yourself.
Also one hint for the future:
Never write the whole program in one run, then start it and be surprised it does not run.
Instead, write two or three lines, then run and see if it does what you expect. Only if yes, write two more lines.
+ 2
What was your aim with writing break? What's it supposed to do?
+ 2
What exactly is supposed to happen when you break?
+ 1
Thankyou HonFu
0
What can i do then?
0
See now...
0
I want to break
When the guess==random numb
0
The program should print ("you won") like msg
Or if=!numb
Then ("you lost")
0
Anna
Thankyou so much