473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

concatinating strings to int... or something :)

(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
Jul 18 '05 #1
2 1569
WIdgeteye wrote in news:pa****************************@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/
Jul 18 '05 #2
On Sun, 25 Jul 2004 18:44:45 +0000, Rob Williscroft wrote:
WIdgeteye wrote in news:pa****************************@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. :)
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: bearophile | last post by:
Hello, here are a four more questions (or suggestions) for the language (probably people have already discussed some of/all such things: I've seen the contracts for Python:...
7
by: TinTin | last post by:
Hello, How do I concatinate a variable. Here's the scenarios: declare @var1 varchar(20) declare @var2 varchar(20) declare @var3 varchar(20) declare @var4 varchar(20) .. ..
20
by: Trevor | last post by:
I have a couple of questions regarding C# strings. 1) Sometimes I see a string in someone else's code like: string foo = @"bar"; What does the '@' do for you? 2) Is there a performance...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
9
by: Steven | last post by:
Hello, I have a question about strcmp(). I have four words, who need to be compared if it were two strings. I tried adding the comparison values like '(strcmp(w1, w2) + strcmp(w3, w4))', where...
3
by: sophie_newbie | last post by:
I am converting TIFF images of patents to PDF files. Each patent comes in about 20 seperate TIFF images and I want to put them all in the one PDF file. Is there a way to do this? Using the Image...
6
by: Christian Blackburn | last post by:
Hi Gang, When encoding HTML strings it'll convert things like " --> &rsquo and the like using Server.HTMLEncode(). However, is there a command to make sure strings don't contain valid SQL...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
1
by: Sharat Koya | last post by:
I have a the following xml node. <doc tag1="a" tag2="b" tag3="c" docTag1="d" docTag2="e"/> I would like to output "abc" I have the following XPATH2.0 so far //doc/@*] which returns a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.