I often deal with heterogeneous datasets and I acquire them as dictionaries in my python routines. I usually face the problem that the key of the next entry I am going to add to the dictionary already exists. I was wondering if there exists a more "pythonic" way to do the following task: check whether the key exists and create/update the corresponding pair key-item of my dictionary
myDict = dict() for line in myDatasetFile: if int(line[-1]) in myDict.keys(): myDict[int(line[-1])].append([line[2],float(line[3])]) else: myDict[int(line[-1])] = [[line[2],float(line[3])]]