0

This program always shows break outside the loop !

Suggest something to resolve this https://code.sololearn.com/c55O4DHU63oE/?ref=app

24th Apr 2019, 5:49 PM
Vedant mishra
Vedant mishra - avatar
12 Respostas
+ 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(...)
25th Apr 2019, 5:26 AM
Anna
Anna - avatar
+ 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.
24th Apr 2019, 7:41 PM
HonFu
HonFu - avatar
+ 2
What was your aim with writing break? What's it supposed to do?
24th Apr 2019, 7:25 PM
HonFu
HonFu - avatar
+ 2
What exactly is supposed to happen when you break?
24th Apr 2019, 7:31 PM
HonFu
HonFu - avatar
+ 1
Thankyou HonFu
24th Apr 2019, 7:43 PM
Vedant mishra
Vedant mishra - avatar
0
What can i do then?
24th Apr 2019, 7:20 PM
Vedant mishra
Vedant mishra - avatar
0
See now...
24th Apr 2019, 7:28 PM
Vedant mishra
Vedant mishra - avatar
0
I want to break When the guess==random numb
24th Apr 2019, 7:29 PM
Vedant mishra
Vedant mishra - avatar
0
The program should print ("you won") like msg Or if=!numb Then ("you lost")
24th Apr 2019, 7:32 PM
Vedant mishra
Vedant mishra - avatar
0
Anna Thankyou so much
25th Apr 2019, 2:06 PM
Vedant mishra
Vedant mishra - avatar