0

Indentation error in break,can someone help.

x=input() print("ch") if x==1: print("ch1") break elif x==2: print("ch2")

17th Jun 2019, 10:10 AM
Gandalf99
Gandalf99 - avatar
10 Respuestas
+ 4
you use break in loops. x=input() print("ch") if x=="1": print("ch1") elif x=="2": print("ch2")
17th Jun 2019, 11:29 AM
Choe
Choe - avatar
+ 3
Break is more indented than print. That's verboten. It has to be on the same indentation level: if x == 1: print() break
17th Jun 2019, 10:20 AM
Anna
Anna - avatar
+ 2
I guess you have used an extra space before the break statement and possibly before 3rd print statement. But I'm not sure. Please re-indentate your code.✌🏼
17th Jun 2019, 10:18 AM
thiru mal
thiru mal - avatar
+ 2
Please upload your code to the code playground and post a link here
17th Jun 2019, 11:03 AM
Anna
Anna - avatar
+ 1
I tried that But it's still not working
17th Jun 2019, 10:19 AM
Gandalf99
Gandalf99 - avatar
+ 1
It's stil not working,did it run in yours? If i'm keeping break in line with print then it's causing 'error break outside loop' and else it's causing indentation error
17th Jun 2019, 10:27 AM
Gandalf99
Gandalf99 - avatar
17th Jun 2019, 11:07 AM
Gandalf99
Gandalf99 - avatar
+ 1
Choe thanks but i saw somehere on the internet they used break with if condition and it was running without any error,
17th Jun 2019, 3:17 PM
Gandalf99
Gandalf99 - avatar
17th Jun 2019, 3:26 PM
Gandalf99
Gandalf99 - avatar
+ 1
Even in this app's tutorial they have used if with break.
17th Jun 2019, 3:27 PM
Gandalf99
Gandalf99 - avatar