Why?
shopping_list = ['apple', 'banana', 'pineapple', 'orange']
for item in shopping_list:
print(item)
shopping_list = ['apple', 'banana', 'pineapple', 'orange']
for i in range(len(shopping_list)):
print(shopping_list[i])
from itertools import cycle
my_cycle = cycle([1, 2, 3])
for i in my_cycle:
print(i)
def shopping_list():
print(1)
yield 'apple'
print(2)
yield 'orange'
print(3)
yield 'banana'
print(4)
yield 'pineapple'
for item in shopping_list():
print(item)
def squares():
i = 0
while True:
i += 1
yield i * i
https://docs.python.org/3/library/itertools.html#itertools.cycle
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for number in numbers:
if number == 3 or number == 4:
numbers.remove(number)
print(numbers)