# Mirroring Text¶

What happens if we add the letter to both sides of the new string that we’re making?

Try changing the phrase and see what effects you can generate.

csp-9-3-1: Change the mirroring program to mirror the phrase "Time to Panic" with a single exclamation point in the middle, to make the printed words look like this: cinaP ot emiT!Time to Panic. How do you do it?
• Make the phrase "Time to panic!"
• That would give us !cinaP ot emiTTime to Panic!.
• Change the newString in line 1 to "!" instead of ""
• We can start our accumulator with something in it.
• Change the right hand side of line 4 to letter + "!" + newstring + letter
• That would give us !!c!i!n!a!P! !o!t! !e!m!i!T!Time to Panic! -- exclamation points between the letters in the first half of the mirror.
• Change the right hand side of line 4 to letter + newstring + "!" + letter
• That would give us !cinaP ot emiT!T!i!m!e! !t!o! !P!a!n!i!c!! -- exclamation points between the letters in the second half of the mirror.

The accumulator doesn’t have to be set to be an empty string. You can put something in the accumulator, and then it will show up in the middle of the mirrored phrase.

(Char_In_Middle)

csp-9-3-2: When the variable letter contains the "W" from Wizard, how many exclamation points are in newString?
• One
• There is just the one in the accumulator to start.
• Two
• If we just mirrored the string, there would be only two. But we are mirroring with something in the accumulator.
• Three
• That is true at the end, but not when letter contains the first letter of "Wizard"
• Four
• At most, there will be three in newString.
        csp-9-3-3: The phrase "A but tuba" is a palindrome.  The letters are the same forward and backward.  The below program generates the output: "abut tub a<=>a but tuba"  Put the lines in the right order with the right indentation.newStr = "<=>"
phrase = "a but tuba"
---
for char in phrase:
---
newStr = char + newStr + char
---
print(newStr)


Note

Discuss topics in this section with classmates.