loop.py
= ["Hello", "Python"]
words
for word in words:
print(word)
Hello
Python
Starting with the same list we used before, each item in the list gets printed on its own line.
loop.py
= ["Hello", "Python"]
words
for word in words:
print(word)
Hello
Python
On the contrary, if we loop over a string we see that each character gets printed on its own line.
loop.py
= "Hello Python"
phrase
for letter in phrase:
print(letter)
H
e
l
l
o
P
y
t
h
o
n