TheRodMeister
8/10/2018 - 12:58 AM

Iterate through a list and print each item




list_of_names = ['rod', 'bob', 'nick', 'susie', 'jeff'] #list of names
currentIndex = 0 #set starting value of current index to 0, which is for rod.
maxIndex = len(list_of_names)-1 #to find the max index length of any list, use len() subtract 1 because indexes start at 0
while currentIndex <= maxIndex: #current index must be below or = to max index to run code block.
    print(list_of_names[currentIndex]) #print the list with current index.
    currentIndex += 1 #increase the current index by one to iterate to next index.














rod
bob
nick
susie
jeff