+ 1

What's the difference between ' and " in Python?

For example, output of print('hello') and print("hello") is the same.

28th Apr 2017, 2:03 AM
cruisers_hs
cruisers_hs - avatar
5 Réponses
+ 12
In python you can define a string using ether. They will both work.
28th Apr 2017, 2:13 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 10
Some languages make you think twice about what their inventors were high on while putting together their craft. Python is weird (especially if learnt after C, C++ and Java).
28th Apr 2017, 5:13 AM
Tusiime Innocent Boub
Tusiime Innocent Boub - avatar
+ 6
There is no technical difference between them. However, "The cat's furry tail." is a valid string, as well as 'He said "Hello!" before leaving.'. So if you want to save yourself some headaches and escapes, use the appropriate one. Good rule of thumb is to use double quotes whenever you have a string, that might be displayed to the user.
28th Apr 2017, 2:16 AM
Tob
Tob - avatar
+ 6
You understood, good. Just for your knowledge in most os the other languages ' c ' is used for characters (char type means single value) and "c" is string.
28th Apr 2017, 3:24 AM
Meharban Singh
Meharban Singh - avatar
0
I understood. thanks. XD
28th Apr 2017, 2:27 AM
cruisers_hs
cruisers_hs - avatar