Answers for "python get last element of iterator"

3

get last element of a list python

a = [1, 2, 3, 4]
print(a[-1])
#prints: 4

print(a[-2])
#prints: 3
Posted by: Guest on January-16-2021
0

python get last element of iterator

*_, last = iterator # for a better understanding check PEP 448
print(last)
Posted by: Guest on October-21-2021

Code answers related to "python get last element of iterator"

Python Answers by Framework

Browse Popular Code Answers by Language