removing spaces between 2 names

S

saif.shakeel

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

Steven Howe

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
 
7

7stud

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

sph

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
 
H

half.italian

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(" "))
 
A

Ant

....
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... ;-)
 

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
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top