for
loops¶
Sources¶
This lesson is based on the Software Carpentry group’s lessons on Programming with Python.
Basics of for
loops¶
Loops allow parts of code to be repeated some number of times.
Let’s consider an example. Suppose we want to take a word and print out each letter of the word separately. We could do the following:
In [1]: word = 'snow' In [2]: print(word[0]) s In [3]: print(word[1])