List comprehension


is there a fixed syntax for list comprehension,

cubes_by_four = [i**3 for i in range(1,11) if i**3%4==0 ]

ok, this syntax i got it ,but for more complex code, i cannot imagine it


This article on DigitalOcean explains the syntax a bit more, including more complex examples:


Also see the following material in the official Python 3 documentation:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.