Sometimes you need to combine a string with something that isn’t a string. In order to do that, you have to convert the non-string into a string.
print "I have " + str(2) + " coconuts!"
This will print
I have 2 coconuts!.
str() method converts non-strings into strings. In the above example, you convert the number
2 into a string and then you concatenate the strings together just like in the previous exercise.
Now try it yourself!
Run the code as-is. You get an error!
str() to turn
3.14 into a string. Then run the code again.