What is the need for using str()



Why should I convert anything into a string. Can someone please explain me, in what way the str() is command useful??

Replace this line with your code.


well for example if you want to join a string and a number together:

pi = 3.14
print "pi is " + str(pi)

because if you simply do:

pi = 3.14
print "pi is " + pi

you get an error


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