Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Convert between mutable lists and immutable tuples
locked_config = ("dark_mode", 14, "monospace")
# 1. Convert tuple to mutable list to make an edit
editable = list(locked_config)
editable[1] = 16 # Change font size from 14 to 16
# 2. Convert back to tuple to lock the settings
final_config = tuple(editable)
print("Original tuple:", locked_config)
print("Updated mutable list:", editable)
print("Final locked tuple:", final_config)