Back to Lesson
State Cleanup
Safely remove elements from dictionaries using popping methods.
Instructions
- Given.
session = {"id": 101, "user": "admin", "token": "xyz", "expires": "today"} - Removeusing the
"token"method and store the value in a variable. Print that value..pop() - Attempt to removeusing
"cache"and print the result..pop("cache", "No cache") - Print the finaldictionary.
session
main.py
main.py
Ctrl + Enter