Explicit String Conversion, differences


#1

I'm new to python and want to understand some of the nuances of string formatting

The code below works in my Python Compiler but not in Codeacademy. Both result in the same output.

print "The value of pi is around ", str(3.14)
print "The value of pi is around " + str(3.14)

The value of pi is around 3.14
The value of pi is around 3.14

BTW I do see that there is "spacing difference."

str(3.14) adds an extra space (2 spaces between "around 3.14"
"+str(3.14) only has a single space between "around 3.14"

Why is this for both questions?

Thank you,


#2

@microsurfer32847,

Have a read
http://stackoverflow.com/questions/21542694/difference-between-using-commas-concatenation-and-string-formatters-in-python