> For the complete documentation index, see [llms.txt](https://george-jen.gitbook.io/data-science-and-apache-spark/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://george-jen.gitbook.io/data-science-and-apache-spark/loop-statement-for-statement.md).

# for loop

```
words = ['cat', 'window', 'defenestrate']
for w in words:
    print(w, len(w))

#cat 3
#window 6
#defenestrate 12
```

```
for i in range(5):
    print(i)
#0
#1
#2
#3
#4
​
```

range(5, 10)

5, 6, 7, 8, 9

range(0, 10, 3)

0, 3, 6, 9

range(-10, -100, -30)

-10, -40, -70

```
a = ['Mary', 'had', 'a', 'little', 'lamb']
for i in range(len(a)):
    print(i, a[i])
    
#0 Mary
#1 had
#2 a
#3 little
#4 lamb
```
