0

why assignment operator does not work in a print function?

num1=10 num2=20 print("num1 + num2 =", num1=+num2)

31st Jul 2018, 11:14 AM
Probin Sinha
2 odpowiedzi
+ 2
because that is output to the console, everything within the parentheses is being sent to the print function and while you can use complex expressions as arguments an assignment statement is not a valid argument for the function, basically you are just confusing the computer now you could do print("num1 + num2=", num1+num2) that would display : num1 + num2 = 30
31st Jul 2018, 11:23 AM
StealthyTaco
StealthyTaco - avatar
+ 1
thanks
31st Jul 2018, 11:42 AM
Probin Sinha