Python Sequence Unpacking with Records

It's abstraction that Python provides, that links back to the infamous ABC language that I discussed in one of my earlier posts. One concept that’s easy to use but powerful to understand is sequence unpacking: records = [   ("Alice", (25, "Engineer", "NY")),   ("Bob", (30, "Designer", "SF")), ] for name, (age, role, _) in records:   print(f"{name} is a {age}-year-old {role}") This shows how unpacking binds only what you care about: name, age and role are only variables that are used for binding and while the other '_' becomes a throwaway variable. #PythonLearning #BackendEngineering

To view or add a comment, sign in

Explore content categories