How to use iterator with a tuple to print the items in Python

1 Answer

0 votes
tpl = ("python", "c", "c++", "php")

it = iter(tpl)

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


'''
run:

python
c
c++
php

'''

 



answered Nov 23, 2018 by avibootz

Related questions

1 answer 179 views
1 answer 291 views
2 answers 328 views
1 answer 276 views
...