PRO TIP For Using Dictionaries In Python (ft. get & setdefault)



PRO TIP For Using Dictionaries In Python (ft. get & setdefault)

PRO TIP For Using Dictionaries In Python (ft. get & setdefault)

Here’s a pro tip you can use with dictionaries in Python. I see a lot of people missing out on these 2 features and performing a lot of redundant checks in their code. While your if checks aren’t necessarily wrong, they can be simplified 🙂

â–¶ The Complete Guide To Mastering Python:
https://python-guide.com/

â–¶ Follow me on Instagram:
https://www.instagram.com/indentlyreels

â–¶ Join the chat on Discord:
https://discord.gg/u89bkX4ch5

00:00 Intro
00:13 How a dictionary works
01:02 get()
01:51 setdefault()
02:09 What is the difference?
03:19 Summing it up

Comments are closed.