Skip to content
Advertisement

Transform list to dictionary with ID’s and content [closed]

Given list is llist = ['4|right', ' 2|left', ' 2|down', ' 2|right']

And the output must be like this:

JavaScript

Advertisement

Answer

The provided output is invalid (a set cannot hold dictionaries as those are not hashable), assuming you want a list of dictionaries:

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement