Tuple Unpacking in Python
Level 252 keystrokes
This unpacks a tuple into individual variables in a single assignment statement.
Python code
# Create a tuple with two values (x and y coordinates)1point = (10, 20)# Unpack the tuple into two separate variables# x gets the first value, y gets the second2x, y = point# Print both values using f-string formatting3print(f"x={x}, y={y}")Output
x=10, y=20
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
=× 4,× 3"× 2(× 2)× 2{× 2}× 2