Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Practice tuple packing, sequence unpacking, and variable swapping
x = 10
y = 20
# 1. Swap x and y in a single Pythonic step
x, y = y, x
# 2. Pack and unpack user profile data
user_tuple = ("dev_lead", "active", 120)
role, status, score = user_tuple
print(f"Swapped: x = {x}, y = {y}")
print(f"Role: {role} | Status: {status} | Score: {score}")