4.3.1 Creating Tuples & Immutability

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):

# Create multi-element and single-element tuples
server_config = ("192.168.1.1", 8080, "HTTPS")
empty_tuple = ()

# Notice the trailing comma required for single-element tuples!
single_item_tuple = ("production",)

print("Config:", server_config)
print("Empty tuple:", empty_tuple)
print("Single-item tuple:", single_item_tuple)
print("Type of single-item:", type(single_item_tuple).__name__)
Open in Live Interactive Python Sandbox →