Home > Net >  How does this call the print function?
How does this call the print function?

Time:08-07

I have this piece of code:

stuff = print(123)

and when running it, 123 gets printed out even though I was never calling it and only assigning it to the variable stuff. Why does this happen? Also, if I decide to add print(stuff) after that line, besides getting,123, None is also seen as an output.

CodePudding user response:

usually a function always returns something. But here basically you are printing the number using the print function and returning none. That is why it's returning none after 123.so if you want to avoid the none just use 'stuff' and it will call for the function 'print' which returns nothing but the values put in it.

CodePudding user response:

stuff = 123
print(stuff)

I think this is what you are trying to do

  • Related