What is the difference between print(' ')and print(" ")?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between print(' ')and print(" ")??

2nd Sep 2017, 6:19 AM
Vibhas Pandey
Vibhas Pandey - avatar
9 Answers
+ 2
a=' hello! hey i heard about bill 's marraige ' print(a)---> error a=" hello! hey i heard about bill 's marraige " print(a)---> no error ------------------------------------------ b= " he said , " I want money. " " print(b)---> error b= ' he said , " I want money. " ' print(b)---> no error ### hope it helped ####
2nd Sep 2017, 12:44 PM
sayan chandra
sayan chandra - avatar
+ 11
@Larry is right if it were C, C++, C# or Java in those language there is a difference between ' ' and " " ' ' is actually used for a single character while " " is used for strings in python and JavaScript (also probably Ruby) you can use either or a combination of both
2nd Sep 2017, 10:34 AM
Burey
Burey - avatar
+ 2
single quotes for character and double quotes for string
2nd Sep 2017, 6:52 AM
Larry Cubillas
Larry Cubillas - avatar
+ 2
in 1st a string ends at ' (after bill) rest generates error in 2nd a we made the compiler understand that string is from " to " no error on ' in 1st b string ends at 2nd " compiler generated error for rest in 2nd b we made compiler understand string is from ' to ' no error
2nd Sep 2017, 12:48 PM
sayan chandra
sayan chandra - avatar
+ 1
thankyou Michelle
2nd Sep 2017, 10:12 AM
Vibhas Pandey
Vibhas Pandey - avatar
+ 1
hi Larry I think Michelle is right because I was able to write both print('hi') and print("hi ")and both worked and that's what made me confused anyway thanks to you also for helping me
2nd Sep 2017, 10:15 AM
Vibhas Pandey
Vibhas Pandey - avatar
0
a very big thx to you Sayan you made me more clear about it
2nd Sep 2017, 6:23 PM
Vibhas Pandey
Vibhas Pandey - avatar
0
✌👌good to know it..
2nd Sep 2017, 6:23 PM
sayan chandra
sayan chandra - avatar
0
here is a small code that shows HOW TO OMIT ERRORS EVEN IF U ARE USING SAME QUOTES LIKE 1st a and 1st b **read code comments and output comments to get the idea** https://code.sololearn.com/cqOgACBjGnj3/?ref=app
2nd Sep 2017, 6:38 PM
sayan chandra
sayan chandra - avatar