0

' AND " difference?

pythn eg. >>> print('Hello world!') Hello world! Me 1 >>> print( " Hello world! " ) Hello world! Me 2 >>> print(' "Hello world! " ') "Hello world!" Me 3 >>> print( ' Hello world! ") SyntaxError: EOL while scanning string literal If ' and " are the same, why "Me 3" results Error? I don't want to tell my self that they look different or it is the rule...

7th Jul 2020, 3:56 AM
Lin Tzu
Lin Tzu - avatar
5 Réponses
+ 7
They aren't same. If you start from " then, you have to close it with this only. See the following example:- print(" ' ' ") # prints ' ' print(' " " ') # prints " " If you will not close it with the same, it will give you an exception(EOL error)
7th Jul 2020, 4:23 AM
Arctic Fox
Arctic Fox - avatar
+ 2
Lin Tzu For the next time around, please put the relevant language in the thread tags to improve context clarity👌
7th Jul 2020, 6:06 AM
Ipang
+ 1
Thanks a lot!
7th Jul 2020, 5:36 AM
Lin Tzu
Lin Tzu - avatar
+ 1
"EOL while scanning string literal" means thar the interpreter did not find the ending quote
7th Jul 2020, 5:36 AM
Bilbo Baggins
Bilbo Baggins - avatar