Python quotes

I was building my first store catalog program, and it wasn’t computing the way I expected it to. The values I assigned to the variables didn’t work. I used three quotes, (") because the value was a multi-lined description.

I peeked at the solution video on youtube and he was using single quotes, (") and it seemed to work on multiline.

Can you post a picture of your code?

Did the strings in the video just get wrapped by the learning environment text editor? If this is just the codecademy learning environment an easy way to check is to view the line numbering (wrapping wouldn’t increase the counter, leaves a blank instead).

Using triple quotes lets you use multiline but the strings you create contain actual newline characters and such since they won’t be escaped like the typical string literal. Text wrapping n the editor is just a visual effect for the sake of the developer, lines aren’t actually broken up.

multiline_str = ''' This is
a mutliline
string.'''

print(multiline_str)  # output now contains those new lines
Out: This is
a mutliline
string.
1 Like

Thank you for y’alls reply. The reason it wasn’t computing was because I set the value of the description to (""), which didn’t match the triple quotes, (""") I used for the description.