friendNames = ['Joan', 'Ronan', 'Nikita', 'Augustus'] # Array indices start at 0, not 1! friendIndex = 0 # Loop over each name in the array. # The len() function gets the length of the list. while friendIndex < len(friendNames): # Use square brackets to get a name from the array. friendName = friendNames[friendIndex] # Tell your friend to go home. # Use + to connect two strings. self.say(friendName + ', go home!') # Increment the index to get the next name from the array. friendName = friendNames[friendIndex] # Go back and build a fence to keep the ogres out.
You simply add one to
friendIndex += 1.