Out of curiosity is it possible to write the following logic as a nice dict comprehension?
a = "a c\nb c\nn q\n".split('\n')[:-1]
output = {}
for line in a:
tmp = line.split(' ')
output[tmp[0]] = tmp[1]
I wrote the following, but without a temporary assignment I have to split twice which is unfortunate:
{line.split(' ')[0]:line.split(' ')[1] for line in a}
Is something more elegant possible?