Get the First and Last Character
Beginner · Write the code · from Python Strings: Create, Access, Slice, and Manipulate Text
From the lesson: Python Strings: Create, Access, Slice, and Manipulate Text
Think about your phone. Almost everything you see on the screen is text: names in your contacts, messages from friends, search results, notifications. Behind the scenes, all of that text is handled by strings.
Read the lessonYou are given a variable word set to "Programming". Print the first character and the last character on separate lines.
Expected output:
P
gUse string indexing to access each character.
word = "Programming"
# Print the first character
# Print the last character
More Strings exercises
- Build a Greeting with ConcatenationBeginner
- Reverse a StringBeginner
- Predict the Slice OutputBeginner
- Fix the Bug: Mutating a StringBeginner
- Check If a Word Is in a SentenceBeginner
- Extract a Domain from an Email AddressBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz