Single Statement In Python
Categories: Python
If the suite of an if clause consists only of a single line, it may go on the same line as the header statement.
Here is an example of a one-line if clause −
Program of Single Statement in python
#!/usr/bin/python
var = 100
if ( var == 100 ) : print "Value of expression is 100"
print "Good bye!"
Output -
When the above code is executed, it produces the following result −
Value of expression is 100
Good bye!