@
3 months ago
@charan123country asked

In Python, what happens if we use single quotes and double quotes at the same time?

Kelish Rai
Expert
last month
Kelish Rai answered

Hi Charan,

You can use both in Python, but a single string must start and end with the same type of quote.

These are fine:

text1 = "Hello"
text2 = 'Hello'

You can mix them inside the string to avoid escaping:

msg1 = "It's a sunny day"
msg2 = 'She said, "Keep learning."'

But this is not valid because the quotes do not match:

text = "Hello'

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Learn Python Basics course.