I have a string which I read from a .csv file:
shopping_lists = 'apple pie,corn bread,red wine\nready soups,milk,coffee\nwhole milk'
I want to get a list of sets like:
[{'apple pie','corn bread','red wine'},{'ready soups', 'milk', 'coffee'},{'whole milk'}]
I tried this code:
s = shopping_lists.split()
L = [set(i.split(',')) for i in s]
But I got the wrong result:
[{'apple'}, {'corn', 'pie'}, {'bread', 'red'}, {'wine'}, {'ready'}, {'coffee', 'soups', 'milk'}, {'whole'}, {'milk'}]
What went wrong, and how can I fix it?