+ 2

Py

Hi guys, Why does the code give an error? print("print("print")")

9th Jun 2019, 7:33 AM
Lili
Lili - avatar
5 Respostas
+ 4
Try this instead : print("print('print')")
9th Jun 2019, 9:44 AM
Mohammad Fahad Sayed
Mohammad Fahad Sayed - avatar
+ 10
print() expects a string "print("print")" is not a valid string because you use double quotes inside double quotes You can either escape the inner double quotes like this: print("print(\"print\")") or use double quotes within single quotes: print('print("print")') or the other way round: print("print('print')")
9th Jun 2019, 7:49 AM
Anna
Anna - avatar
+ 1
if you use " in print statements, if you mention any " in between the " in print statement you should excempt them by giving \ before them or you can use print statement with " or ' and you can mention viceversa quotes in print statement
2nd Sep 2021, 5:18 PM
Sandeepkumar Arisella
Sandeepkumar Arisella - avatar
0
# Hi! That’s because the syntax is invalid. You have two strings and one function you are trying to print out as one argument. If you want to print mulitiple things (objects) in Python, you have to separate them with commas: >>> print("print(", print, ")") print( <built-in function print> )
5th Dec 2021, 8:00 AM
Per Bratthammar
Per Bratthammar - avatar
0
Here is correct solution. Print("Print")
1st Jun 2022, 8:09 AM
Hrithika Reddy
Hrithika Reddy - avatar