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

how to convert one string seperated by commas into individual strings (python)

how can i change this.

a= ['man, boy, mum']

into

a=['man', 'boy', 'mum']

I have tried replacing the commas with (‘) but it does not work.
any help will be appreciated

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

>Solution :

Here is a quick answer for you

>>> a = ['man, boy, mun']
>>> result = a[0].split(',')
>>> result
['man', ' boy', ' mun']

Now you need to clean up the white spaces (‘ ‘).

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