Creating multiple nested dictionaries from .txt file
问题 I am trying to create a dictionary consisting of multiple dictionaries. I am creating this from a .txt file: chrY 6 8 + chrY 3 5 + chrX 10 11 + chrX 13 15 - My desired output would be: {'chrY': {'+' : {'start': [3 , 6], 'end': [5, 8]}}, 'chrX': {'+' : {'start': [10], 'end': [11]} , '-': {'start' : [13], 'end' : [15]}}} My code so far consists of: import sys first_dict = {} intron_dict = {} def main(): with open(sys.argv[1], 'r') as intron: for line in intron.readlines(): line = line.split()