What is the difference, if any, between using single quote and double quote in a python dictionary? [duplicate] What is the difference, if any, between using single quote and double quote in a python dictionary? [duplicate] python-3.x python-3.x

What is the difference, if any, between using single quote and double quote in a python dictionary? [duplicate]


There's no difference; ' and "can be used interchangeably. There's no inherent reason to favor one over the other unless your string has a quotation mark in it (in that case, you have to surround the string with the opposite quotation mark).

Other than that, it's just personal preference. If you come from a Java background then you might prefer double quotes for strings and single quotes for "characters" (which are really just one letter strings). But at the end of the day it's the same thing.


The differences is that when you have a string like:

''a''

It will throw a syntax-error because it contains two quotes side by side

so you need to do double quotes like:

"'a'"

And same thing doing the opposite:

""a""

Will throw an error.

'"a"'

won't throw an error

(on stack-overflow the displayed code is already doesn't look right)