python for loop string code example
Example 1: how to loop through string in python
for i in "Hello":
print(i)
Example 2: python for loop
#an object to iterate over
items = ["Item1", "Item2", "Item3", "Item4"]
#for loop using range
for i in range(len(items)):
print(items[i])
#for loop w/o using range
for item in items:
print(item)
Example 3: python iterate over string
word = "test"
for letter in word:
print(letter)