Python Forum

Full Version: variable prints without being declared.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm a beginner new to this site and I don't know if this has been posted before, so please be patient with me.
This isn't an error in as much as I'm curious. I declared a variable with the print function.

var = print("Hello")
It printed even without me calling the variable. Why is that?
var is not printing, the str "Hello" is printing. The value of var is None because that is the value returned by the print function.
(Jul-11-2021, 12:05 AM)deanhystad Wrote: [ -> ]var is not printing, the str "Hello" is printing. The value of var is None because that is the value returned by the print function.

Thanks for that. I figured it out thanks to you.