p
y
c
h
a
l
l
e
n
g
e
r
Home
Python Basics
Strings I
Exercise: Get last character from string
Exercise: Get last character from string
Here, we try to get the last character from a string using square brackets and an index number. Again, there is a small mistake. Fix the code and run it again. Remember that you can also use negative index numbers.
reset
text = "String magic!"
last_char = text[13]
print(last_char)
Python
Setting up Python environment...
Output