Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list as the list [1,1,2,3,5] that are less than 5. Currently it prints as
1
1
2
3
5
My code
a = [1,1,2,3,5,8,13,21,34,55,89]
count = 0
for i in a:
if i<=5:
count+=1
print(i)
[1,1,2,3,5]instead of1 1 2 3 5? If so, it's probably advisable to drop the part of the question that just recaps the homework problem you were on when this came up. It's confusing as currently presented.[1,1,2,3,5]is less than or equal to 5...