Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uppercase every other word in a string using split/join

I have a string:

string = "Hello World" 

That needs changing to:

"hello WORLD" 

Using only split and join in Python.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help?

string = "Hello World" 

split_str = string.split()

Can’t then work out how to get first word to lowercase second word to uppercase and join

>Solution :

string = "Hello World"
split_str  = string.split()
print(' '.join([split_str[0].lower(),split_str[1].upper()]))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading