logo CodeStepByStep logo

doubleslash

Language/Type: Python basics escape sequences mystery print

What is the output from the following code? (Assume that a tab is expanded into eight spaces.)

print("Dear \"DoubleSlash\" magazine,")
print()
print("\tYour publication confuses me. Is it")
print("a \\\\ slash or a //// slash?")
print("\nSincerely,")
print("Susan \"Suzy\" Smith")

(NOTE ABOUT SPACING: Many students fail this problem by not understanding how the \t character works, causing them to have the wrong number of spaces. A tab inserts multiple spaces until the total number of characters on the current line so far is a multiple of 8. So for example, in the string "hi\thello\tgoodbye\tbeautiful\thi", the first \t becomes 6 spaces (because "hi" is 2 characters, so it takes 6 more to get to 8), the second \t is 3 spaces (because "hello" is 5 characters wide, so it takes 3 more characters to get to 8), the third is 1 (because "goodbye" is 7 characters), and the fourth \t is 7 spaces (because "beautiful" is 9 characters, so it takes 7 more to get to 16, which is the next multiple of 8).

output

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.