You are viewing a single comment's thread. Return to all comments →
Not wrong, but you have not used list comprehension. Consider a list called 'a' with even and odd numbers. Now suppose you want to create a list 'b' that contains only the even numbers of list 'a'.
One way to do this in the usual way with a loop:
Using list comprehension this would look like this single line:
The challenge in this problem is creating nested list comprehesions, which can be tricky. See PEP 202.
(Sorry for the broken formatting, but it's not possible to code-format in replies here in HR.)