Beginning Python

We start with the same list we had in the chapter.

loop.py
words = ["Hello", "Python"]

for word in words:
    print(word)

Each item in the list gets printed on its own line:

$
python loop.py
Hello
Python

If we loop over a string:

loop.py
phrase = "Hello Python"

for letter in phrase:
    print(letter)

We see that each character in the string gets printed on its own line:

$
python loop.py
H
e
l
l
o
 
P
y
t
h
o
n