Comprehensions are an effective way to build lists using a notation reminiscent of set theory.
They are one of the nicest concepts Python borrowed from Functional programming, and they allow you to write code that's both compact and fast. In this video I show you how to create a comprehension, and how to use the "if" keyword as a filter to specify conditions that the elements of the final list must satisfy. For more information, see the notebooks below (notebooks will open on Google Colab - no installation required)
Embedded video, part of the following courses:
Computer Programming at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/3xjmpf94
Coding for Scientists at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/yedumefr
Смотрите видео List comprehensions: a quick way to create lists in Python онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь PatchyPython 08 Сентябрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 133 раз и оно понравилось 1 людям.