956 B
956 B
type, title, xp, duration, difficulty
| type | title | xp | duration | difficulty |
|---|---|---|---|---|
| challenge | The Mirror | 75 | 30 | 3 |
The Mirror
[INCOMING — Mission Control, Earth]
Cadet, a palindrome reads the same forwards and backwards.
racecar.level.madam.A reverse-slice flips a string in one move:
"Hello"[::-1] # "olleH"A string is a palindrome when it equals its reverse. The
==operator returnsTrueorFalsedirectly.Implement
mirror(s)that returns a dict with three keys:
original— the inputreversed— the input reversedpalindrome—Trueif equal to its reverseMatch case exactly —
racecarandRaceCarare different inputs.[END TRANSMISSION]
Your Task
In starter/starter.py, build the dict using [::-1] and ==.
Objectives
mirror("racecar")["palindrome"]isTruemirror("hello")["palindrome"]isFalse- All three keys correct for any input string