0

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

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by sneekula
0

Use replace():

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

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

1

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.