If else alternate that is shorter and that can also be made a variable?? I know it but forgot the syntax | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

If else alternate that is shorter and that can also be made a variable?? I know it but forgot the syntax

It goes like this "Variable=( condition)? True:False " I think and not even sure if it's in python or JavaScript please If you know that I'd appreciate your help

17th Jul 2023, 1:56 PM
Indiphile Menziwa
Indiphile Menziwa - avatar
3 Answers
+ 4
Please tag the relevant programming language, not "//". Search for the keyword "ternary operator". In Python, the ternary expression is written like x = yes if condition else no
17th Jul 2023, 2:29 PM
Lisa
Lisa - avatar
+ 2
Not possible in python but in Java, C# & JavaScript and some other languages
17th Jul 2023, 2:15 PM
A͢J
A͢J - avatar
0
Sorry My bad, Thanks
17th Jul 2023, 2:54 PM
Indiphile Menziwa
Indiphile Menziwa - avatar