Python Forum
question about list comprehension - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: question about list comprehension (/thread-12720.html)



question about list comprehension - adriaanNL - Sep-09-2018

I am practicing for the python PCAP exam and i don't understand this excercise:

How many empty lines will the following snippet send to the console?
l = [[c for c in range(r)] for r in range(3)]
for x in l:
    if len(x) < 2:
    print()
I do understand easy list comprehensions but not this one with c for c in range®.

If someone could explain this I would be very thankful.


RE: question about list comprehension - buran - Sep-09-2018

it is list comprehension inside list comprehension. the result will be list of lists