concatinating strings to int... or something :)

WIdgeteye None at none.none
Sun Jul 25 18:34:46 CEST 2004


On Sun, 25 Jul 2004 18:44:45 +0000, Rob Williscroft wrote:

> WIdgeteye wrote in news:pan.2004.07.25.13.27.56.119159 at none.none in 
> comp.lang.python:
> 
>> (Simple test code below)
>> 
>> What I am trying to do is print;
>> 
>> you win $50 
>> 
>> what I am getting is;
>> 
>> you win $ 50    with the space between the $ and 50.
>> 
>> I tried; print arf + barf
> 
> print arf + str( barf )
> 
>> but it tells me you can't concat strings to numbers.
> 
>> 
>> mon = int(raw_input("get number"))
>> 
>> barf = 2 * mon
>> 
>> arf = "you win $"
>> 
>> print arf, barf
>> 
> 
> print "%s%d" % (arf,barf)
> 
> http://docs.python.org/lib/typesseq-strings.html
> 
> Rob.


Thanks, especially for the link.  :)



More information about the Python-list mailing list