DEV Community

Free Python Code
Free Python Code

Posted on

How to remove value from dictionary python

Hi 🙂🖐

In this post, I will share with you how to remove values from dictionary or dict in Python.

myData = {'a': 1, 'b': 2, 'c': 3}

def remove_item(key, data):
    del myData[key]

    return myData


print(remove_item('a', myData))
Enter fullscreen mode Exit fullscreen mode

Result

{'b': 2, 'c': 3}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)