Learn
Well done! However, now we have the first letter showing up both at the beginning and near the end.
s = "Charlie" print s[0] # will print "C" print s[1:4] # will print "har"
- First we create a variable
s
and give it the string"Charlie"
- Next we access the first letter of
"Charlie"
usings[0]
. Remember letter positions start at 0. - Then we access a slice of
"Charlie"
usings[1:4]
. This returns everything from the letter at position 1 up till position 4.
We are going to slice the string just like in the 3rd example above.
Instructions
1.
Set new_word
equal to the slice from the 1st index all the way to the end of new_word
. Use [1:len(new_word)]
to do this.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.