Using quotation marks for strings

Hi, I was trying to complete the assignment on strings in the section called “Variables and Data Types for Data Analysis in Python”, but for some reason, my code wasn’t working.

Screen Link:
https://app.dataquest.io/c/57/m/200/variables-and-data-types/9/escaping-special-characters

My Code:

I was asked to complete these three questions:

  • Assign the string Facebook's new motto is "move fast with stable infra." to a variable named motto.
  • Notice there’s a . character at the end of Facebook's new motto is "move fast with stable infra." — you’ll need to include the . character in your answer.
  • Display the variable motto using print() — displaying motto is necessary for answer checking.

I answered the question with this code:

motto = 'Facebook\'s new motto is "move fast with stable infra".'
print(motto)

What I expected to happen:
Output: Facebook’s new motto is “move fast with stable infra.”
Variable: motto

What actually happened:
The output of your code didn’t match what we expected.

Replace this line with the output/error:
- actual + expected

- Facebook's new motto is "move fast with stable infra".

I realised that when I looked at the answer for the questions, that instead of using the code:

motto = 'Facebook\'s new motto is "move fast with stable infra".'
print(motto)

It used the code:

motto = 'Facebook\'s new motto is "move fast with stable infra."'
print(motto)

This didn’t make any sense to me as in the example to a similar problem, they used this code:

# Notice the backslash character in 'Facebook\'s'
motto = 'Facebook\'s old motto was "move fast and break things".'
print(motto)

This is what I followed for my answer. It never showed anything similar to the actual answer in the learning area of the module. I would like some clarification if I missed anything in the “learn” area that would explain what I was following was wrong

Hi @anniecurran10029 and welcome to the community!

While the Learn section has the . outside the quotation marks, in the Instructions section, we are asked to produce a string with the . inside the quotation marks. While this isn’t technically an error, I can see how it could cause some confusion while learning on this screen.

According to the Chicago Manual of Style (CMOS), terminating punctuation should always be inside of quotation marks (with a few exceptions). So, if anything, it’s the Learn section that could be considered “wrong”…in a grammatical sense. That said, making them slightly different forces the learner to pay close attention to the syntax which I think is ultimately the purpose here.