How can I only parse/split this list with multiple colons in each element? Create dictionary
<p>I have the following Python list:</p>

<pre><code>list1 = ['EW:G:B&lt;&lt;LADHFSSFAFFF', 'CB:E:OWTOWTW', 'PP:E:A,A&lt;F&lt;AF', 'GR:A:OUO-1-XXX-EGD:forthyFive:1:HMJeCXX:7', 'SX:F:-111', 'DS:f:115.5', 'MW:AA:0', 'MA:A:0XT:i:0', 'EY:EE:KJERWEWERKJWE']
</code></pre>

<p>I would like to take the entries of this list and create a dictionary of key-values pairs that looks like</p>

<pre><code>dictionary_list1 = {'EW':'G:B&lt;&lt;LADHFSSFAFFF', 'CB':'E:OWTOWTW', 'PP':'E:A,A&lt;F&lt;AF', 'GR':'A:OUO-1-XXX-EGD:forthyFive:1:HMJeCXX:7', 'SX':'F:-111', 'DS':'f:115.5', 'MW':'AA:0', 'MA':'A:0XT:i:0', 'EW':'EE:KJERWEWERKJWE'}
</code></pre>

<p>How does one parse/split the list above <code>list1</code> to do this? My first instinct was to try <code>try1 = list1.split(":")</code>, but then I think it is impossible to retrieve the "key" for this list, as there are multiple colons <code>:</code></p>

<p>What is the most pythonic way to do this? </p>

<p>You can also use <a href="https://docs.python.org/3/library/stdtypes.html#str.partition" rel="nofollow"><code>str.partition</code></a></p>

<pre><code>list1 = ['EW:G:B&lt;&lt;LADHFSSFAFFF', 'CB:E:OWTOWTW', 'PP:E:A,A&lt;F&lt;AF', 'GR:A:OUO-1-XXX-EGD:forthyFive:1:HMJeCXX:7', 'SX:F:-111', 'DS:f:115.5', 'MW:AA:0', 'MA:A:0XT:i:0', 'EW:EE:KJERWEWERKJWE']

d = dict([t for t in x.partition(':') if t!=':'] for x in list1)

# or more simply as TigerhawkT3 mentioned in the comment
d = dict(x.partition(':')[::2] for x in list1)

for k, v in d.items():
    print('{}: {}'.format(k, v))
</code></pre>

<p>Output:</p>

<pre><code>MW: AA:0
CB: E:OWTOWTW
GR: A:OUO-1-XXX-EGD:forthyFive:1:HMJeCXX:7
PP: E:A,A&lt;F&lt;AF
EW: EE:KJERWEWERKJWE
SX: F:-111
DS: f:115.5
MA: A:0XT:i:0
</code></pre>

python dictionary split