Back to Freecodecamp

Challenge 177: String Mirror

curriculum/challenges/english/blocks/daily-coding-challenges-python/69738771fb5a7b8b24cca2a3.md

latest1.2 KB
Original Source

--description--

Given a string, return a new string that consists of the given string with a reversed copy of itself appended to the end of it.

--hints--

mirror("freeCodeCamp") should return "freeCodeCamppmaCedoCeerf".

js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mirror("freeCodeCamp"), "freeCodeCamppmaCedoCeerf")`)
}})

mirror("RaceCar") should return "RaceCarraCecaR".

js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mirror("RaceCar"), "RaceCarraCecaR")`)
}})

mirror("helloworld") should return "helloworlddlrowolleh".

js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mirror("helloworld"), "helloworlddlrowolleh")`)
}})

mirror("The quick brown fox...") should return "The quick brown fox......xof nworb kciuq ehT".

js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mirror("The quick brown fox..."), "The quick brown fox......xof nworb kciuq ehT")`)
}})

--seed--

--seed-contents--

py
def mirror(s):

    return s

--solutions--

py
def mirror(s):
    reversed_s = s[::-1]
    return s + reversed_s