I have two lists
names = ['Bruce', 'Clark', 'Peter', 'Logan', 'Wade']
heroes = ['Batman', 'Superman', 'Spiderman', 'Wolverine', 'Deadpool']
From these lists, I want a dict of {'name': 'hero'} for each name,hero using a lambda function. Here's my desired output:
{'Bruce': 'Batman', 'Clark': 'Superman', 'Peter': 'Spiderman', 'Logan': 'Wolverine', 'Wade': 'Deadpool'}
I have the code below that works but when I try to put it together using a lambda function I don't get as expected. Here is the code that works using dictionary comprehensions
dc_dict = {name: hero for name, hero in zip(names, heroes)}
print(dc_dict)
I am trying to replicate the above logic using lambda function and that doesn't work as expected. Here is what I have come up with.
l_dict = dict(lambda names[name]:heroes[hero] for (name, hero) in zip(names, heroes))
print(l_dict)
TIA