In Javascript (EcmaScript), the following expression is possible:

let a = 10; let b = 20; let result = (a === b) ? 'lala' : 'qweqwe'; 

How to do this in Python (3), if, of course, it is possible?

    1 answer 1

    Analogue of the ternary operator in Python:

     res = "Yup" if a==b else "Nope" 

    Or through a tuple:

     res = ("no","yes")[a==b]