Tutorialspoint

What is the difference between single and double quotes in python?

In Python strings are made with single as well as double quotes. What is the difference between single and double quotes in python?



1 Answer
Malhar Lathkar

A string as a sequence of characters not intended to have numeric value. In Python, such sequence of characters is included inside single or double quotes. As far as language syntax is concerned, there is no difference in single or double quoted string. Both representations can be used interchangeably. However, if either single or double quote is a part of the string itself, then the string must be placed in double or single quotes respectively.

For example a text Hello “Python” is to be stored as a string, then one should use

str1='Hello "Python"'

On the other hand, if string should resemble Hello ‘Python’ then it should be declared as follows:

Str2="Hello 'Python'"
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.