0
Removing item from list value in dictionaries - Python
What would be the best way to remove the value ‘pastrami’ from the following dictionary: sandwiches = {'club':['turkey', 'pastrami', 'ham', 'lettuce', 'tomato'],'meat_feast':['turkey', 'pastrami', 'ham', 'salami'],'plain':['pastrami', 'mustard']}
2 Respostas
+ 6
for k in sandwiches:
sandwiches[k] = [_ for _ in sandwiches[k] if _ != 'pastrami']
Don't know if it's the best way
0
Thanks everyone, they were very useful 👍