I have a huge file (with around 200k inputs). The inputs are in the form:
A B C D B E F C A B D D
I am reading this file and storing it i
A dictionary comprehension makes short work of this task:
>>> s = [['A','B','C','D'], ['B','E','F'], ['C','A','B','D'], ['D']] >>> {t[0]:t[1:] for t in s} {'A': ['B', 'C', 'D'], 'C': ['A', 'B', 'D'], 'B': ['E', 'F'], 'D': []}