-2

Is word "python" and 'python' are different expression??

I want to know the differnecce between the type of the expressions "python" and ’python’

arshovon
  • 13,270
  • 9
  • 51
  • 69

3 Answers3

1

They both are same. Double quotes are typically used for string representation, while single quotes are used for regular expressions, dict keys, and SQL. As a result, both single quotes and double quotes represent strings in Python, but we may need to use one over the other at times.

For more clarity:

type("python") and type('python') if you check this both will output as string.

Even if you write this:

if("python" == 'python'):
print("True")
else:
print("False")

You will see this code snippet will print true. So there is no differences between "python" and 'python'

Minhaj98
  • 376
  • 3
  • 7
0

No there is no difference between "python" and 'python'. Both of them will get treated as strings. One advantage could be if your string needs to have one of those quotes in them, eg if John's car is your string then you do "John's car".

0

In python, strings can be defined between a a pair of ' or a pair of ". So there is no actual difference between 'python' and "python" BUT there is a difference between 'python's' and "python's".

'python's' 

will spit back an error, because it thinks there is a missing ', and the s is not apart of the string because of this.

"python's"

does not spit back an error, because the ' in this object is considered part of the string. So, using "" to define strings can be better than '' due to ability to add apostrophe's within your string.

njt121
  • 1
  • 1