Code Lab BetaBUILD. RUN. DISCOVER.
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
PYTHON STRUCTURES / CHAPTER 06 / Learn / LESSON 06
List comprehension — compact list:
nums = [1, 2, 3, 4] squares = [n * n for n in nums if n % 2 == 0] print(squares) # [4, 16]
Read it as: “for each n in nums, if condition, append expression”.
Learn: comprehension + if.
STREAM IDLE
›