What is the need for using str()


#1



https://www.codecademy.com/courses/python-beginner-sRXwR/1/4?curriculum_id=4f89dab3d788890003000096


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.


#2

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


#3

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