How To Convert List Of String To Dictionary In Python
I have a list of strings. I want to convert to dictionary. I got the output after scraping the data. ['Name:Dr. Mak', 'Location: India, Delhi'] ['Name:Dr. Hus MD', 'Location:US, NY
Solution 1:
dict(s.split(':') for s in list_of_strings)
Edit: removing whitespace
dict(map(str.strip, s.split(':')) for s in list_of_strings)
Post a Comment for "How To Convert List Of String To Dictionary In Python"