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

Deleting braces from array

I am trying to delete "{" and "}" from array which looks like:

data = [{'Python'}, {'5'}, {'Golang'}, {'4'}, {'PHP'}, {'3'}]

Solutions like converting array/list to string and after that replacing symbols do not work as expected.

Could you help with it, please?

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

Im waiting output like:
[‘Python’, ‘5’, ‘Golang’, ‘4’, ‘PHP’, ‘3’]

>Solution :

This array looks to be a list of sets with a single element.
You can create a new list of strings:

data = [''.join(my_set) for my_set in data]

The output is:

['Python', '5', 'Golang', '4', 'PHP', '3']
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