Hi Guys,

Sorry if this is so stupid but i just cant get it to work!!

Basically if the user enters in a number of words:

------------------------------------
input: my name is

i want output to be: mynameis
------------------------------------
or
------------------------------------
input: word one word two

i want

output: wordonewordtwo
------------------------------------
any recommendations on how i can go about doing this??

Thank you in advance..

Struggling irishman

Use replace():

s = "word one word two"
# replace space with no-space
ms = s.replace(' ', '')
print ms  # wordonewordtwo

Hi,

Thanks! That works great. Im also trying to do the opposite.. i have tried isupper method to find upper case strings but thats only for full strings??

I want to try now to get the word
--------------------------
say WordOneWordTwo
--------------------------

and then print out

--------------------------
Word One Word Two
--------------------------

Is there anything i can do this with??

Thanks for your help..

One of the ways to do this would be:

s = "WordOneWordTwo"

new_s = ""
for ix, c in enumerate(s):
    # skip start of string s
    if c.isupper() and ix != 0:
        new_s += " "
    new_s += c
    
print new_s  # Word One Word Two
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.