Senior
Is it possible to iterate over a string in Python?
sobes.tech AI
Answer from AI
Yes, in Python, you can iterate over a string. A string in Python is a sequence of characters, and it supports iteration over each character.
Example:
s = "Hello"
for char in s:
print(char)
This code will print each character of the string on a separate line. Iterating over a string is useful for analyzing, processing, or transforming text.