If- elif - else and unreachable code (keep your Python away from this trap!)

Опубликовано: 29 Май 2026
на канале: PatchyPython
170
3

Try this code in your browser: click here
https://tinyurl.com/6hkfpbd6

When running multiple tests over conditions that are not mutually exclusive (example water is hot - water is very hot), it's important that you do them in the right order; otherwise, some of your code may become unreachable, in the sense that no possible execution path will ever lead to those instructions. Generally, this is a sign of logical flaw in your code. For more information and to try out the code, click on the link above - a notebook will open in your browser, no need to install Python on your machine.

Embedded video, also part of the following courses:
Computer Programming at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/4umjbjvp
Coding for Scientists at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/539p4b5f