Parsing a string of key-value pairs as a dictionary
Note it is much easier to read if you chop up the comprehension into blocks, instead of having them all on one line

You could use unpacking to remove some usages of line.split

&gt;&gt;&gt; {
...    int(k): v
...    for line in data.split() 
...    for k, v in (line.split(':'),)
... }
{41: 'n', 43: 'n', 44: 'n', 46: 'n', 47: 'n', 49: 'n', 50: 'n', 51: 'n', 52: 'n', 53: 'n', 54: 'n', 55: 'cm', 56: 'n', 57: 'n', 58: 'n'}


Or if the first argument can be of str type you could use dict().

This will unpack the line.split and convert them into a key, value pair for you

&gt;&gt;&gt; dict(
...    line.split(':') 
...    for line in data.split() 
... )
{'41': 'n', '43': 'n', '44': 'n', '46': 'n', '47': 'n', '49': 'n', '50': 'n', '51': 'n', '52': 'n', '53': 'n', '54': 'n', '55': 'cm', '56': 'n', '57': 'n', '58': 'n'}