How to use iterator with a string to print the characters in Python

1 Answer

0 votes
s = "python"
it = iter(s)

print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))


'''
run:

p
y
t
h
o
n

'''

 



answered Nov 24, 2018 by avibootz

Related questions

1 answer 261 views
1 answer 243 views
1 answer 233 views
2 answers 209 views
1 answer 179 views
...