in this article, we'll learn how to Iterate over a list with 2 different ways

1. Using for loop

Example:


#List
list_a = ['Mark', 'Jonh', 'Leo', 'Andrea']

#Iterate over array
for item in list_a:
    print(item)

output

Mark                                                                                                                                  
Jonh                                                                                                                                  
Leo                                                                                                                                   
Andrea 

2. Using while loop

Example:


#List
list_a = ['Mark', 'Jonh', 'Leo', 'Andrea']

i = 0
list_size = len(wordList) 
while i < list_size :
    print(list_a[i]) 
    i += 1

output

Mark                                                                                                                                  
Jonh                                                                                                                                  
Leo                                                                                                                                   
Andrea 

Summary

After knowing the ways to iterate over a list, Probably, you are asking your self, what is the best way to iterate over a list? the answer is the most common way to do that is by using for loop

English today is not an art to be mastered it's just a tool to use to get a result