Home / Python / Control flow

Conditions

if, elif and else choose which code runs. Python groups lines by indentation, not braces. Conditions often sit inside a loop or a function.

score = 72
if score >= 90:
    print("A")
elif score >= 60:
    print("Pass")
else:
    print("Retry")

Test yourself on this