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 176 views
1 answer 132 views
1 answer 147 views
2 answers 90 views
1 answer 88 views
...