0 votes
in Python by
How is a negative index used in Python?

1 Answer

0 votes
by

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
asked Sep 7, 2022 in Python by sharadyadav1986
0 votes
asked Jun 28, 2020 in Python by Robindeniel
...