Why doesn’t Python automatically convert the number to a string?

Does that mean that if it is a str(variable) then I can change the value of the variable instead of changing the string in the print statment every time?

yes, that is then possible. But you might also not know what the value, given it comes from a input field, a database or something else

1 Like


If you say, have a variable called x with a value of 7, and you want to call the value, "x" wouldn’t work.

x = 7
print "x" # returns x in the console
print str(x) # returns 7 in the console
1 Like