Forcing type conversion

Andy Lester andy at petdance.com
Wed May 17 10:27:13 EDT 2000


> How do I get Python to force 'a' and 'b' into strings so that the following
> concatenates instead of trying to add.
> 
> a = 1
> b = 2
> a + ":" + b

The metaphor you're looking for is like so:

  str = "%d:%d" % (a,b)

xoxo,
Andy

--
Andy Lester, andy at petdance.com, http://www.petdance.com
    "Inflammable material is planted in my head
     It's a suspect device that's left two thousand dead."
    "Hey, is this the new Green Day?"





More information about the Python-list mailing list