Use to separate lines and variables during printing:
print "If there was a birth every 7 seconds, there would be: ",births,"births"
, in a print statement splits the elements into one space:
>>> print "foo","bar","spam" foo bar spam
or better to use string formatting :
print "If there was a birth every 7 seconds, there would be: {} births".format(births)
Formatting strings is much more powerful and allows you to do other things, such as filling, filling, aligning, width, specified accuracy, etc.
>>> print "{:d} {:03d} {:>20f}".format(1,2,1.1) 1 002 1.100000 ^^^ 0 padded to 2
Demo:
>>> births = 4 >>> print "If there was a birth every 7 seconds, there would be: ",births,"births" If there was a birth every 7 seconds, there would be: 4 births
Ashwini Chaudhary Jun 17 '13 at 17:58 2013-06-17 17:58
source share