Control flow

if without parentheses โ€” but with a colon

Swift wraps conditions in if condition { }. Python drops the parentheses around the condition and the braces around the body, replacing { } with a colon and indentation:

rating = 4.9
if rating >= 4.8:
    print("top rated")
elif rating >= 4.0:
    print("solid")
else:
    print("needs reviews")

elif is Python's else if โ€” one word, no space. The indentation (4 spaces, by convention) is not just style: it's how Python knows which lines belong to the if block. There is no closing brace to mark the end โ€” dedenting back to the left ends the block.