another one question🐥 | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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 Réponses
+ 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