Dictionary Methods: Getting and Setting Values in Python


Use dictionary methods for safer access and setting of values.

Source Code

print(info.get("name", "Unknown"))
info.setdefault("age", 30)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments