Try this code in your browser: click here
https://tinyurl.com/6hkfpbd6
A special place use of the "if" keyword in Python is within list comprehensions. This so-called "guard" serves to select what elements of the original list or other iterable will be added to the comprehension; it works as a kind of filter. This form of the "if" statement is never followed by an "else". 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