 Back in the chapter on iteration, we used a for loop to iterate through, or traverse, a list of data items. This program takes a list of integers, and then, with a for loop, takes each item in the list and prints it out. Like this. This list is a collection of integers. We can think of a string as a collection of characters and use a similar for loop to get each character in the string and print it out. And here's the result. Another way to traverse a string is by using a for loop with an index. We'll take an index that starts in the range from zero up to but not including the length of the string, which is exactly how the positions in a string are numbered. And each time through the loop, we'll print the character at that particular index. And here are the results. Unlike our first for loop, one advantage of using an index is that you don't have to process every character. For example, we could process every other character by starting our range at zero, going to the end of the string, and incrementing the index by two every time. And there's our output. Or you could find where the first space in the word is by using the find method by running the index in the range from zero up to space index and printing those characters one after another, and that would give us the first word in the string. It's also possible to use a while loop to traverse a string. If you're going to do that, you need to set the index to its initial value before you enter the while loop. Here we're using a compound condition for our while, as long as the index is valid and we haven't reached the first blank in the string, we'll print the character at that index and then we'll move to the next position in the string. Remember that while doesn't automatically add to the index. You have to do it yourself or you'll end up with an infinite loop. And when we run the program, we again get the first word in the string. And there are three different ways to traverse a string with a for loop by item, with a for loop by index, and with a while loop.