Psst! Check what courses we have in our offer, and get them all here to save \$727. Act fast–this deal is available only 3/14–3/21.
Introduction
Quick recap
Indexing and slicing
14. Reversing strings
Summary

Instruction

Great! If you use a negative index as the step, you can actually reverse a string! Take a look:

alphabet = 'abcdefghijklmnopqrstuvwyxz'
alphabet[::-1]


The code alphabet[::-1] means "take all characters (with no lower or upper bound) and go back one index at a time." As a result, we'll get a reversed string!

Exercise

Ask the user to provide a palindrome, a word that reads the same backwards and forwards: Write a palindrome:

If the input is an actual palindrome, write: Correct palindrome. Otherwise write: Not a palindrome.

Stuck? Here's a hint!

To check if the user entered a palindrome, use == palindrome[::-1].