THE WORLD'S LARGEST WEB DEVELOPER SITE

Python and Keyword

❮ Python Keywords


Example

Return True if both statements are True:

x = (5 > 3 and 5 < 10)

print(x)
Run example »

Definition and Usage

The and keyword is a logical operator.

Logical operators are used to combine conditional statements.

The return value will only be True if both statements return True, otherwise it will return False.


More Examples

Example

Using the and keyword in an if statement:

if 5 > 3 and 5 < 10:
  print("Both statements are True")
else:
  print("At least one of the statements are False")
Run example »

Related Pages

The keywords or, and not are also logical operators.

Read more about operators in our Python Operators Tutorial.


❮ Python Keywords