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


#1

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?


#2

Don't flame it cuz im a newbie


#3

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


#4

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