TGViewer
Learn Python Coding Learn Python Coding @pythonre · 40.9K subscribers
Post #8857 1.82K
A collection of useful built-in Python functions that most juniors haven't touched

1️⃣ all and any: a mini rule engine
— all(iterable) returns True if all elements are true
— any(iterable) returns True if at least one is true
Example:
password = "P@ssw0rd123"
checks = [
    len(password) >= 8,
    any(c.isdigit() for c in password),
    any(c.isupper() for c in password),
]

if all(checks):
    print("password is ok")

— You can quickly build readable policy checks without a forest of ifs

2️⃣ enumerate: a handy counter instead of manual indexing
Instead of for i in range(len(list)):
users = ["alice", "bob", "charlie"]
for idx, user in enumerate(users, start=1):
    print(idx, user)

— You get both the index and the value at once. Less chance to shoot yourself in the foot with off-by-one errors

3️⃣ zip: linking multiple sequences
names  = ["alice", "bob", "charlie"]
scores = [10, 20, 15]
for name, score in zip(names, scores):
    print(name, score)

— You can glue several lists into one stream of tuples, do parallel iteration, nicely combine data without manual indices

4️⃣ reversed: reverse without copying
data = [1, 2, 3, 4]
for x in reversed(data):
    print(x)

— reversed returns an iterator, not a new list, which is convenient when you don't want to allocate extra memory

5️⃣ set and frozenset: uniqueness and fast lookup
items = ["a", "b", "a", "c"]
unique = set(items)  # {'a', 'b', 'c'}
if "b" in unique:
    ...

— A great way to kill duplicates and speed up membership checks, plus frozenset is hashable

👩‍💻 @DataScience4
  • ❤ 14
More from @pythonre
  1. Oct 17, 2026😰 15-Hour "Python for Data Science" Course ⚡️ Learn Python for Data Science https://enghu…
  2. Oct 13, 2026https://substack.com/@husseinsheikho?utm_source=share&utm_medium=android&r=3hwnr8 Follow m…
  3. Oct 10, 2026📚 Download 10 Python books for FREE: 1. Think Python — O’Reilly https://t.co/X7y3pX68IW 2…
  4. Oct 7, 2026Python Lists: A Quick Reference 🐍 * Definition: Lists are ordered, mutable collections th…
  5. Oct 7, 2026📱 270 tools for Python developers The repository contains: 🫡 Linters and formatters; 🫡…
  6. Oct 7, 2026Hands On Python Data Science - Data Science Bootcamp Master Python for Data Science with R…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →