0 votes
in Python by (30.8k points)
How is a negative index used in Python?

1 Answer

0 votes
by (30.8k points)

Negative indexes are used in Python to assess and index lists and arrays from the end of your string, moving backwards towards your first value. For example, n-1 will show the last item in a list, while n-2 will show the second to last. Here’s an example of a negative index in Python:

b = "Python Coding Fun"

print(b[-1])

>> n

Related questions

0 votes
...