Back to Lesson

Data Unpacking

Extract elements from a tuple using standard and starred unpacking.

Instructions

  • Given
    user_data = ("alice_smith", "user", True, "admin", "moderator")
  • Use unpacking to assign the first element to
    username
    , the second to
    role
    , and the remaining elements to a list called
    flags
    using the
    *
    operator.
  • Print
    username
    ,
    role
    , and
    flags
    on separate lines.
main.py
main.py