For loop with String
For loop with String
Example
Looping Through a String
Even strings are iterrable
objects, they contain a sequence of characters:
Example
Loop
through the letters in the word "banana":
for x in "banana":
print(x)
Print
each fruit in a fruit list:
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
The for loop does
not require an indexing variable to set beforehand.
Post a Comment