+ 1

another one questionđŸ„

can I write several "if" conditions in a row, without "else"? For example: if (a[i] < j): j = a[i] if (a[i] < s): s = a[i] Or I have to write just like: if (a[i] < j): j = a[i] else: if (a[i] < s): s = a[i]

11th Apr 2020, 5:24 AM
shiryaeva
shiryaeva - avatar
3 Answers
+ 6
Also note the difference between if-if-if and if-elif-elif statements. ✔ In if-if-if the program will read all if statements and determines true or false ✔ In if-elif-elif statements the program reads from the first and if it returns true, it will skip rest of the statements or if it is false then the program continues in the same sequence.
11th Apr 2020, 5:42 AM
Valmob101
Valmob101 - avatar
+ 3
Ya You can write that way also it is helpful in some cases
11th Apr 2020, 5:34 AM
Bhavya Lohami
Bhavya  Lohami - avatar
+ 1
Okeh đŸ» thank you
11th Apr 2020, 5:31 AM
shiryaeva
shiryaeva - avatar