using floats/ints in print and write
joonas at olen.to
Mon Aug 20 20:56:30 CEST 2001
Rajarshi Guha wrote:
> does'nt python 2.2 allow me to use float/int variables in a string
> context. That is I can't write:
> print a + 'hello'
> where a is float or int. Right now I'm using fpformat.fix() to get a string
> value. Is there any other way?
Here are two preferred ways to do that.
>>> a = 3
>>> print str(a)+"hello"
>>> print `a`+"hello"
You can also print them as separate arguments, but
then Python prints a space between them.
>>> print a, "hello"
More information about the Python-list