Py | Sololearn: Learn to code for FREE!



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

6/9/2019 7:33:03 AM


5 Answers

New Answer


Try this instead : print("print('print')")


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')")


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


# 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> )


Here is correct solution. Print("Print")