Delete entire tuple using del keyword Dry Run in PYTHON

Delete entire tuple using del keyword is an interactive PYTHON dry run visualizer from the Tuples programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Delete entire tuple using del keyword Program Code

# Delete entire tuple using del keyword
my_tuple = (10, 20, 30, 40, 50)
print("Tuple before deletion:", my_tuple)

# Delete the tuple
del my_tuple

# Trying to access after deletion causes error
try:
    print(my_tuple)
except NameError as e:
    print(f"\nError after deletion: {e}")

# You cannot delete individual elements
another_tuple = (15, 25, 35, 45)
print(f"\nAnother tuple: {another_tuple}")

# This would cause error (tuples are immutable)
try:
    del another_tuple[1]  # Cannot delete element
except TypeError as e:
    print(f"Cannot delete element: {e}")

# But you can delete the entire tuple
del another_tuple
print("Tuple deleted successfully!")

View the complete Tuples programs page.

Program Console Delete entire tuple using del keyword Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.