Let's say I was given with this text age_gender.txt
Female:18,36,35,49,19
Male:23,22,26,26,26
Here's the code I have so far
file = open("age_gender.txt")
contents = file.read().splitlines()
new_dictionary = dict(item.split(":") for item in contents)
return new_dictionary
When I call the function readfile() this is the output I get, however the list of value is still in quotation marks. How do you convert that each value into a list?
{'Female': '18,36,35,49,19', 'Male': '23,22,26,26,26'}
The output I want to achieve is something like this
{'Female': [18,36,35,49,19], 'Male': [23,22,26,26,26]}