Why use str(2) instead of "2"?


#1



Just wondering why, in the example of "print "I have " + str(2) + " coconuts!"" you wouldn't use "2" instead of str(2)?



#2

In the case of a literal, it would just be one long string. But consider if 2 is a (a dynamic value), such as a return from a function that sends back a number.


#3

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