Python Forum

Full Version: string function doesn't work in script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I don't know if this has been posted before, but when I run the string function in interactive, it works fine, but when it comes to script it doesn't work. Here is my code:
print(str(24))
Why is that?
How is it not working? What do you mean by "when it comes to script it doesn't work"?

There is no need to use the explicit str() function. Print automatically does the conversion for you.
(Jul-13-2021, 02:08 PM)deanhystad Wrote: [ -> ]How is it not working? What do you mean by "when it comes to script it doesn't work"?

There is no need to use the explicit str() function. Print automatically does the conversion for you.

Yeah you're right. I was confused as there were no quotations over the number to indicate that it was a string. Thank you.
Any quotes surrounding a string is a feature of your development environment, not Python. Remember that what you see printed is only a representation of the thing, not the thing itself, and that the representation is just somebody's idea of the best representation.