how to traverse a string in python code example
Example 1: how to loop through string in python
for i in "Hello":
print(i)
Example 2: loop through words in a string python
str = 'Hello! I am Robot. This is a Python example.'
#split string
splits = str.split()
#for loop to iterate over words array
for split in splits:
print(split)
Example 3: python iterate over string
word = "test"
for letter in word:
print(letter)
Example 4: iterate through characters in a string python
for c in "string":
#do something with c