How to remove value from dictionary python

Free Python Code - Apr 28 - - Dev Community

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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player