If is a function or an operator in Python. Just I am curious about it. In my opinion, it is a function because it gives output and accomplishes commands. I know that it is statement.
As seen in the Operator Precedence table, inline if-else (a if cond else b) is an operator.
The if starting a conditional block is, however, neither an operator nor a function because it is a statement, as described in Chapter 3 of the Python documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With