If statement true Python | Example code

If statement concept works on Boolean true and false. If block codes will execute if the Boolean expression evaluates to TRUE. If the Boolean expression evaluates to FALSE then the code inside the block will not execute.

if expression:

Python example if the statement is a true

Simple example code. Try it at least twice, with different inputs. You will get an extra output result, depending on the input.

weight = int(input("Enter suitcase weigh: "))

if weight >= 50:
    print("There is a $25 charge for luggage that heavy.")


If statement true Python

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.