- 2

a = 2 if a == 1: print("one") else: if a == 2: print("two") else: if a == 3: print("ok")

Error

16th Oct 2020, 2:55 AM
Hacker Tamil Tamila
Hacker Tamil Tamila - avatar
6 ответов
+ 1
What you want to achieve can be done with elif keyword . just write elif for else if
16th Oct 2020, 2:59 AM
Hima
Hima - avatar
+ 1
IndentationError in your code. Check this: https://code.sololearn.com/cM1Q635XD8Br/?ref=app
16th Oct 2020, 3:21 AM
Nikolai Ivanov
Nikolai Ivanov - avatar
0
Bro but two stop but error bro
16th Oct 2020, 3:01 AM
Hacker Tamil Tamila
Hacker Tamil Tamila - avatar
0
But it's more correct to use elif here. https://code.sololearn.com/ci0p9pBgPxrF/?ref=app
16th Oct 2020, 3:26 AM
Nikolai Ivanov
Nikolai Ivanov - avatar
0
Nikolai Ivanov Haha, I literally don't know why I said so. Thanks for notifying me .
16th Oct 2020, 3:31 AM
Hima
Hima - avatar
0
a = 2 if a == 1: print("one") else: if a == 2: print("two") else: if a == 3: print("ok") two
11th Dec 2021, 1:59 PM
Daniel 😊😎😉[JS Challenger]
Daniel 😊😎😉[JS Challenger] - avatar