Answers for "remove key in dict"

2

python remove key from dict

my_dict.pop('key', None)
Posted by: Guest on September-03-2020
0

dictionary removing specific key

>>> # Python 3.6, and beyond
>>> incomes = {'apple': 5600.00, 'orange': 3500.00, 'banana': 5000.00}
>>> sorted_income = {k: incomes[k] for k in sorted(incomes)}
>>> sorted_income
{'apple': 5600.0, 'banana': 5000.0, 'orange': 3500.0}
Posted by: Guest on June-03-2021

Python Answers by Framework

Browse Popular Code Answers by Language