To iterate over a list in Python, you can use for loops or list comprehensions.
In this example,
numbers
with integer elements.numbers = [10, 20, 30, 40, 50]
for number in numbers:
print(number)
10 20 30 40 50
In this example,
names
with string elements.names = ['Alice', 'Bob', 'Charlie', 'David']
upper_names = [name.upper() for name in names]
print(upper_names)
['ALICE', 'BOB', 'CHARLIE', 'DAVID']
In this tutorial, we learned How to Iterate Over a List with Index in Python language with well detailed examples.