By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,267 Members | 1,800 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,267 IT Pros & Developers. It's quick & easy.

removing spaces between 2 names

P: n/a
Hi,
Suppose i have a string stored in variable,how do i remove the
space between them,like if i have the name:
"USDT request" in a variable.i need "USDTrequest",without any space .
Thanks

May 15 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
sa**********@gmail.com wrote:
Hi,
Suppose i have a string stored in variable,how do i remove the
space between them,like if i have the name:
"USDT request" in a variable.i need "USDTrequest",without any space .
Thanks

from string import replace
st = 'abcd acdfg xtit'
st.replace(' ','')
'abcdacdfgxtit'

sph

--
HEX: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

May 15 '07 #2

P: n/a
On May 15, 12:14 am, Steven Howe <howe.ste...@gmail.comwrote:
saif.shak...@gmail.com wrote:
Hi,
Suppose i have a string stored in variable,how do i remove the
space between them,like if i have the name:
"USDT request" in a variable.i need "USDTrequest",without any space .
Thanks

from string import replace
st = 'abcd acdfg xtit'
st.replace(' ','')
'abcdacdfgxtit'

sph

--
HEX: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
The methods in the string module are deprecated. Skip the import and
use a string's built in replace() method instead:

s = "hello world"
result = s.replace(" ", "")
print result

May 15 '07 #3

P: n/a
On May 14, 11:00 pm, saif.shak...@gmail.com wrote:
Hi,
Suppose i have a string stored in variable,how do i remove the
space between them,like if i have the name:
"USDT request" in a variable.i need "USDTrequest",without any space .
Thanks
s = "jk hij ght"
print "".join(s.split(" "))

May 15 '07 #4

P: n/a
Ant
On May 15, 7:41 am, 7stud <bbxx789_0...@yahoo.comwrote:
On May 15, 12:14 am, Steven Howe <howe.ste...@gmail.comwrote:
....
from string import replace
st = 'abcd acdfg xtit'
st.replace(' ','')
'abcdacdfgxtit'
....
The methods in the string module are deprecated. Skip the import and
use a string's built in replace() method instead:
This is true, but actually Steven *is* using the string's built in
replace method - the import isn't used in the code! Obviously the
import was a deliberate mistake designed to see if you were
awake... ;-)

--
Ant...

http://antroy.blogspot.com/
May 15 '07 #5

P: n/a
On Mon, 14 May 2007 23:14:23 -0700, Steven Howe wrote:
sa**********@gmail.com wrote:
>Hi,
Suppose i have a string stored in variable,how do i remove the
space between them,like if i have the name: "USDT request" in a
variable.i need "USDTrequest",without any space .
Thanks

from string import replace
st = 'abcd acdfg xtit'
st.replace(' ','')
'abcdacdfgxtit'
The line "from string import replace" is redundant.

--
Steven.
May 15 '07 #6

P: n/a
half.ital...@gmail.com wrote:
s = "jk hij ght"
print "".join(s.split(" "))
"".join(s.split()) is enough.
--
Roberto Bonvallet

May 15 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.