The ternary operator cannot be overloaded. Though you can wrap it up in a lambda/function and use it. For
example
result = lambda x: 1 if x < 3 else 10 print(result(2)) print(result(1000))
Output
This will give the output −
1 10
The ternary operator cannot be overloaded. Though you can wrap it up in a lambda/function and use it. For
result = lambda x: 1 if x < 3 else 10 print(result(2)) print(result(1000))
This will give the output −
1 10