in Python by
How Does The Ternary Operator Work In Python?

1 Answer

0 votes

The ternary operator is an alternative for the conditional statements. It combines true or false values with a statement that you need to test.

The syntax would look like the one given below.

[onTrue] if [Condition] else [onFalse]

x, y = 35, 75

smaller = x if x < y else y


Related questions

0 votes
asked Jun 23, 2019 in PHP by SakshiSharma
0 votes
asked Jun 28, 2020 in Python by Robindeniel
0 votes
asked Nov 24, 2020 in JAVA by sharadyadav1986