Explicit String Conversion
Remember when we talked about thestr()
method a couple of lessons back, and how it turns non-strings into strings? The fancy name for that process is explicit string conversion.
You're explicitly telling Python, "Hey, I know this isn't a string, but I want to turn it into one." Contrast this with just putting quotes around a sequence of characters to make it a string.
Making a number into a string can let you glue together strings and numbers (which Python normally won't allow). Check it out:
print "I have " + str(2) + " coconuts!"
will print "I have 2 coconuts!"