python - How do I change values in a dictionary in one key? -
for example, have key = name. within name, there's birthday, age, , phone number. change birthday keep rest. , i'm trying use existing file have names already.
so if want use tuple key syntax
d[(name, phonenumber)] = birthday
as far using values in pre-existing file need open method.
file = open("filename.csv",r) # assuming have file of comma separated values text = file.read() .split("\n") peps = [p.split(",") p in text] dictionary = {} p in peps: d[(p[column of name] , p[col# phone number)]]=p[#bday]
roughly. there several types of collections in python, {}, [], (), hash , set. recommend read on each here
Comments
Post a Comment