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 ofFacebook'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