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 265 views
1 answer 250 views
1 answer 239 views
2 answers 213 views
1 answer 184 views
...