0

How do i use the else statement

It does not want to work

18th Jun 2018, 12:32 PM
Sean Morrey
22 Respostas
+ 4
if (condition) { statements } else if (condition) { statements } else { statements }
18th Jun 2018, 12:39 PM
Haris
Haris - avatar
+ 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. šŸ˜…
18th Jun 2018, 12:43 PM
Haris
Haris - avatar
+ 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")
18th Jun 2018, 1:15 PM
Haseeb Ahmed Saeed
Haseeb Ahmed Saeed - avatar
+ 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")
18th Jun 2018, 1:17 PM
KrOW
KrOW - avatar
+ 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
18th Jun 2018, 6:09 PM
KrOW
KrOW - avatar
+ 1
thank u
18th Jun 2018, 12:40 PM
Sean Morrey
+ 1
Sean Morrey Please next time, make a better description of your problem. Post an code example and specify which language you use
18th Jun 2018, 1:12 PM
KrOW
KrOW - avatar
+ 1
thanks 4 the help it has finally worked
18th Jun 2018, 1:17 PM
Sean Morrey
+ 1
Sean Morrey I suggest to read better your learning resources before make questions... This is very basic in Python
18th Jun 2018, 1:19 PM
KrOW
KrOW - avatar
18th Jun 2018, 12:38 PM
Sean Morrey
0
It says else is a invalid syntax
18th Jun 2018, 12:43 PM
Sean Morrey
0
It is still saying it is an error
18th Jun 2018, 12:55 PM
Sean Morrey
0
Sean Morrey Can you upload the code here...
18th Jun 2018, 12:56 PM
Haseeb Ahmed Saeed
Haseeb Ahmed Saeed - avatar
0
It says that error is an invalid suntax
18th Jun 2018, 12:59 PM
Sean Morrey
0
syntax*
18th Jun 2018, 12:59 PM
Sean Morrey
0
It will not let me use else at all
18th Jun 2018, 1:07 PM
Sean Morrey
0
x=4 if x==5: print("yes") else: print("no")
18th Jun 2018, 1:14 PM
Sean Morrey
0
You are right sir šŸ‘
31st Jan 2019, 12:59 PM
Jack Marley
Jack Marley - avatar
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
19th May 2020, 6:12 AM
MUHAMMAD SHAHJALAL
MUHAMMAD SHAHJALAL - avatar