Now Try It!


#1

https://www.codecademy.com/en/courses/python-beginner-en-KAgt5/1/3?curriculum_id=4f89dab3d788890003000096

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

#2

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.


#3

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