
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
What is correct syntax of Python if statement?
In Python, if keyword is used to execute on or more statements conditionally. The keyword is followed by a logical expression and : symbol. A block of increased indent containing one or more statements (stmt1 and stmt2 in following illustration) is executed if the expression evaluates to true. If it is not true, statements if any (stmt3 below) after the indented block get executed.
if expr == True: stmt1 stmt2 stmt3
- Related Articles
- What is basic syntax of Python if...else statement?
- What is the syntax of Python if...elif...else statement?
- What is correct syntax to create Python tuples?
- What is correct syntax to create Python lists?
- What is correct syntax to create Python dictionary?
- What is the correct syntax for NOT LIKE in MySQL?
- What is syntax of tuple declaration in Python?
- What is basic syntax of Python for Loops?
- What is python .. ("dot dot") notation syntax?
- Bash declare Statement Syntax and Examples
- What is Syntax Tree?
- Correct MySQL INSERT ... ON DUPLICATE KEY syntax?
- What is if statement in JavaScript?
- What is if...else if... statement in JavaScript?
- What is the basic syntax to access Python Dictionary Elements?

Advertisements