concatinating strings to int... or something :)

W

WIdgeteye

(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
but it tells me you can't concat strings to numbers.
I have read the tutorial (and probably missed the answer)
could someone please tell me how to get rid of that
infernal space?

Thanks.





mon = int(raw_input("get number"))

barf = 2 * mon

arf = "you win $"

print arf, barf
 
R

Rob Williscroft

WIdgeteye wrote in 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top