+ 1

syntax error in print

the condition for the print is whatever we typed inside "" or ' ' will be printed or displayed but when i tried of placing a single quoted text inside a single quotes or a double quoted text inside a double quotes (i.e print(""Hello world!"")or print(''Hello world!'')) it shows an syntax error(File "..\Playground\", line 8 print(""Hello world!"") ^ SyntaxError: invalid syntax) why...

4th Jan 2018, 11:55 AM
Anwar Badurudeen
Anwar Badurudeen - avatar
2 Respuestas
+ 7
print(""Hello world"") is invalid. print("Hello world") is valid. print('Hello world') is valid.
4th Jan 2018, 12:46 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
single quote in double quote is valid, e.g. print(" ' hello world' ") double quote in single quote is also valid, e.g. print(' "hello world" ') using three single or double quotes is also valid, e.g. print('''hello world''') or print("""hello world""") is this what you want to ask?
4th Jan 2018, 1:11 PM
Iken Sama
Iken Sama - avatar