2.8 KiB
2.8 KiB
In [ ]:
iterable=range(5)
my_list=[]
for x in iterable:
if x<=3:
my_list.append(x**2)
print (my_list)In [ ]:
my_list=[x**2 for x in iterable if x<=3]
print (my_list)In [ ]:
# your solution hereIn [ ]:
# your solution here