Python doesn't have the traditional ternary operator that most programming languages do. Instead we have "conditional expressions".

Table of contents
Python doesn't have typical ternary operators
Here we have an if
-else
statement:
ifamount==1:noun="item"else:noun="items"
ifamount==1:noun="item"else:noun="items"
Many programming languages allow you to take code like this, that assigns a variable to one of two values based on a condition, and turn that into a single line of code:
noun=amount==1?"item":"items"
noun=amount==1?"item":"items"
That strange ?
...:
syntax is often called a ternary operator.
Python doesn't support that syntax: that isn't valid Python code. Instead, we have something called a conditional expression.
Python's conditional expressions (a.k.a. inline if
)
Python's conditional expression looks like …