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.
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.
In python, if is a statement used for conditional execution. It's not considered a function nor an operator.
I don't think you 'll find a better answer than the python docs.
The if statement is not a function, as evidenced by this list of built-in functions. It is also not an operator, about which you can find information here.
It is in fact a compound statement.
Considered if is built-in construction in the core of the language I think it can be considered less of a function but more an operator. If can be described as a set of instructions but at the high level (such as python) it's operator.