What's the difference between str(2) and "2"?


Aren't they the same thing after all? Why you have to change 2 to a string by using str() when you can just put 2 in quotation marks?


Don't flame it cuz im a newbie


in this case you could, but what if you prompt the user for a number, or you retrieve a value from a database and you need to convert to string? In this case, yes, you can just put quotation marks, but this is not always possible


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.