4.3.3 Converting: tuple() & list()

Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in 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)
Open in Live Interactive Python Sandbox →