0
How do i use the else statement
It does not want to work
22 odpowiedzi
+ 4
if (condition) {
statements
} else if (condition) {
statements
} else {
statements
}
+ 4
That's the generic c style syntax.
For python its a little different.
if condition :
statements
elif condition :
statements
else :
statements
I'm a little rusty in python. 😅
+ 2
This will give you indentation error. The correct way to write code in python is below.
x=4
if x==5:
print("yes")
else:
print("no")
+ 2
This is Python language. You have to understand that indentation its FUNDAMENTAL in Python.... You have to add indentation to if/else statements:
x=4
if x==5:
print("yes")
else:
print("no")
+ 2
I dont want be rude and im sorry if its seemed in this way, but you have to understand that you cannot open a new thread for a very basic concept like this that you find in EVERY Python tutorial.... Your question its "How do i use the else statement" and we are ended in an indentation error (that Python have sure notified you about)... If everyone make post for this VERY basic topics, this service would be full of unuseful questions and many users will not responde. I repeat. Read you learn resource and if you dont understand a concept, ask (posting an example code also) but remember: programming is not only about code, you MUST have curiosity, willingness to learn and try to figure out for yourself as long as you can
+ 1
thank u
+ 1
Sean Morrey Please next time, make a better description of your problem. Post an code example and specify which language you use
+ 1
thanks 4 the help it has finally worked
+ 1
Sean Morrey I suggest to read better your learning resources before make questions... This is very basic in Python
0
It says else is a invalid syntax
0
It is still saying it is an error
0
Sean Morrey Can you upload the code here...
0
It says that error is an invalid suntax
0
syntax*
0
It will not let me use else at all
0
x=4
if x==5:
print("yes")
else:
print("no")
0
You are right sir 👍
0
if condition:
statement
elif condition:
statement
else:
statement
................
Or
if condition:
statement
if condition:
statement
....................
Or
if condition:
statement
else:
statement
Or
if condtion:
statement