Files
curriculum/1.solar-system/3.strings/05.the-mirror/index.md

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 returns True or False directly.

Implement mirror(s) that returns a dict with three keys:

  • original — the input
  • reversed — the input reversed
  • palindromeTrue if equal to its reverse

Match case exactly — racecar and RaceCar are different inputs.

[END TRANSMISSION]

Your Task

In starter/starter.py, build the dict using [::-1] and ==.

Objectives

  • mirror("racecar")["palindrome"] is True
  • mirror("hello")["palindrome"] is False
  • All three keys correct for any input string