Interview Prep/Python for DevOps/Language essentials & functions

What does `enumerate` and `zip` do, and what is `zip(strict=True)`?

BeginnerConceptLanguage essentials & functions
Answer

enumerate(seq, start=1) yields (index, item). zip(a, b) pairs items and stops at the shortest input, silently dropping extras. zip(a, b, strict=True) (3.10+) raises ValueError if lengths differ, which catches bugs like "12 hosts but 11 IPs".

for n, (host, ip) in enumerate(zip(hosts, ips, strict=True), start=1):
    print(f"{n}. {host} -> {ip}")
All Python for DevOps questions Roadmap: Python for automation

More on Language essentials & functions