Is there python function in standard library like
def cond(condition, true, false):
if condition:
return true
return false
x = 20
s = cond(x > 10, "x greater than 10", "x less or equals 10")
Is there python function in standard library like
def cond(condition, true, false):
if condition:
return true
return false
x = 20
s = cond(x > 10, "x greater than 10", "x less or equals 10")
Python has a ternary-like operator (it's actually called a conditional expression), which reads like this:
s = "x greater than 10" if x > 10 else "x less or equals 10"