How does python handles " in a string when \ is not provided?

github logo ・1 min read

I am a beginner in python. I knew that " is a special character and needs \ to print it. But how does python handles " in a string when \ is not provided? For example

s = "Google," "facebook"
print(s)

prints "Google,facebook". How does python skips the middle "?

twitter logo DISCUSS (2)
markdown guide
 

In this case you actually have two strings which are concatenated with each other. See related part of Python docs.

 

In this example, the strings get concatenated. Also, you don't necessarily need \ to escape ". You could also do s = 'Google," facebook' and the " would be printed normally.

Classic DEV Post from Jan 24

What's your favorite Markdown editor?

I try to write all my notes in markdown, but I'm new to MD editors

FarzanRashid profile image

Tip: You can configure your dev.to reading experience, such as using sans serif fonts.

Go to your the "misc." section of your settings.

Customize dev.to