elif

Short for else if: an extra case in an if statement, tested only when every earlier condition was false.

In more detail

Python checks the conditions in order and runs only the first true one, then skips the rest, so order matters: put the strictest test first. A final else catches anything left; without it, nothing may happen.

Example

if score >= 90:
    grade = "A"
elif score >= 80:
    grade = "B"
else:
    grade = "C"

Related terms

Taught in

References

Certification courses