Python Shorthandf If


If Statement in One Line

If you have only one statement to execute, you can put it on the same line as the if statement.

Example

One line if statement:

if a > b: print("a is greater than b")
Try it Yourself »


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.