New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Can i iterate through a string
for example for 'hello'. is it possible to iterate to print h \n e \n l \n l \n o \n
1 Answer
+ 6
Yes, string's an iterable:
for char in string:
print(char)
That prints all the characters, each on separate line.