Answers for "-2 in python"

0

-2 in python

# assuming you were not looking for the number -2
# -2 as an index to an array-like object (as a list) will return
# its second-to-last element

# Here is an example
l = [1,27,34,5,6,7,5,84,289,63,52]
print(l[-2])
>>> 63
Posted by: Guest on July-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language