+ 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

5th Feb 2017, 1:11 PM
harris
1 Odpowiedź
+ 6
Yes, string's an iterable: for char in string: print(char) That prints all the characters, each on separate line.
5th Feb 2017, 2:25 PM
DotJason