Negative Index in Python
Level 119 keystrokes
This accesses the last character of a string using negative indexing. -1 refers to the last character.
Python code
# A negative index counts from the end: -1 is the last character# The last character of "Python" is "n", so n is printed1print("Python"[-1])Output
n
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 2-× 1(× 1)× 1[× 1]× 1