Reverse a Word
Beginner · Write the code · from Python Slicing: Master Indexing for Strings, Lists, and Tuples
From the lesson: Python Slicing: Master Indexing for Strings, Lists, and Tuples
Imagine a pizza cut into 8 slices, numbered 0 through 7. You don't always want the whole pizza. Sometimes you want slices 2 through 5. Sometimes you want every other slice. Sometimes you want the last three slices.
Read the lessonUse slicing to reverse the string word and print the result. The output should be nohtyp.
word = 'python'
# Reverse the word using slicing and print it
More Slicing exercises
- Get the Middle ItemsBeginner
- Predict the Slice OutputBeginner
- Extract Even-Indexed ItemsIntermediate
- Fix the Slicing BugIntermediate
- Palindrome CheckerAdvanced
All Python exercises · 50 practice problems · Data Structures quiz