concatinating strings to int... or something :)

Rob Williscroft rtw at freenet.co.uk
Sun Jul 25 14:44:45 EDT 2004


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.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list