Now Try It!


I am not sure I understand the code supplied as an example for this exercise. The range doesn't play any role in this. I can put any number > 3. Or I just can say range(3)...

c = ['C' for x in range(5) if x < 3]
print c


yes, you can. But we do have to demonstrate how to use conditions in list comprehension, it is then better to start with a simple example, even though there is a more efficient way.


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