Correct behavior?

asker vizcaynot at gmail.com
Thu Apr 26 20:34:15 EDT 2007


Hello:
I have next Python 2.5.1 instructions:

>>> a=12.34
>>> b=11.23
>>> print a+b
23.57

>>> print "%15.2f" % (a+b)
          23.57

But:
>>> print "%15.2f" % a+b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'float' objects

Is this correct for Python to issue this error?

Thanks




More information about the Python-list mailing list