The For Loop |Section 4|Celestial Warrior

1 year ago
2

Create a for loop blockthat iterates through the following list and prints out each item of the list in each iteration.

mylist = [1, 2, 3, 4, 5]

Expected output:

1
2
3
4
5

mylist = [1, 2, 3, 4, 5]
for i in mylist:
print(i)

Create a for loop that iterates through all the items of the following list and prints out the item if the item is greater than 2.

mylist = [1, 2, 3, 4, 5]

Expected output:

3
4
5

mylist = [1, 2, 3, 4, 5]
for i in mylist:
if i > 2:
print(i)

Loading comments...