p
y
c
h
a
l
l
e
n
g
e
r
Home
Python Basics
Strings I
Exercise: Get first character from string
Exercise: Get first character from string
Here, we try to get the first character from a string using square brackets and an index number. But, there is a small mistake. Fix the code such that the first character is correctly printed to the console.
Premium
reset
text = "String magic!"
first_char = text[1]
print(first_char)
Python
Setting up Python environment...
Output