Remove elements using discard() - no error Dry Run in PYTHON

Remove elements using discard() - no error is an interactive PYTHON dry run visualizer from the Sets 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.

Remove elements using discard() - no error Program Code

# Remove using discard() - no error if element not found
nums = {10, 20, 30, 40, 50}
print("Original:", nums)

# Discard existing element
nums.discard(30)
print("After discard(30):", nums)

# Discard non-existent element - NO ERROR
nums.discard(100)
print("After discard(100) - no error:", nums)

# Multiple discards
nums.discard(20)
nums.discard(200)
print(f"Final set: {nums}")

View the complete Sets programs page.

Program Console Remove elements using discard() - no error Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.