Day 51/100 of #100DaysOfPythonTips 🐍
Most if / elif chains are a code smell.
If your logic looks like this:
“If A do this, if B do that…”
You probably need a dispatch table — not more ifs.
Use a dictionary that maps keys → functions.
#Python#pythonlearn#100DaysOfCode
Day 46/100 of #100DaysOfPythonTips 🐍
Python’s for loop has an else.
The else block runs only if the loop didn’t break.
“If I never found it, do this.”
It’s perfect for search logic — clean, readable, and almost nobody uses it.🧠🐍
#Python#pythonlearn#100DaysOfCode
Day 42/100 of #100DaysOfPythonTips 🐍
* set is implemented as a hash table → average O(1) lookup
* list is a dynamic array → O(n) linear scan
* If you care about existence, use a set.
* If you care about order or duplicates, use a list.
#Python#pythonlearn#100DaysOfCode
Day 38/100 of #100DaysOfPythonTips
🐍: Why __name gets mangled to _Class__name
It’s not for security.
It’s not real privacy.
It’s simply to prevent accidental overrides in subclasses.
#Python#pythonlearn#100DaysOfCode