0

'break' outside loop (SyntaxError) on my first calculator code

https://code.sololearn.com/c8oTUYdJYibM/#py I don't what i do wrong with the 7th line. I just press 'enter' to go to the next line and type break and when i execute the code, it failed. But if i changed it to for example print('NO'), it's working! Please enlighten me THX

25th Jun 2020, 11:54 AM
M.O.HONOR
M.O.HONOR - avatar
3 odpowiedzi
+ 8
It's because there is no loop to be broken there. Use exit() instead :)
25th Jun 2020, 11:59 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
M.O.HONOR break - keyword works only for breaking out of the loops like for and while . To quit of if block use exit() function which terminates program execution
25th Jun 2020, 1:38 PM
uday kiran
uday kiran - avatar
0
Thx a lot both of u :)
26th Jun 2020, 5:21 AM
M.O.HONOR
M.O.HONOR - avatar