Check element existence using 'in' operator Dry Run in PYTHON

Check element existence using 'in' operator 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.

Check element existence using 'in' operator Program Code

# Check if element exists in tuple using 'in' operator
fruits = ("Apple", "Banana", "Cherry", "Mango", "Orange")
print("Tuple:", fruits)

# Check existence
print(f"Is 'Apple' in tuple? {'Apple' in fruits}")
print(f"Is 'Grape' in tuple? {'Grape' in fruits}")

# Using 'not in'
print(f"Is 'Kiwi' NOT in tuple? {'Kiwi' not in fruits}")

# Practical use: conditional execution
search = input("\nEnter fruit to search: ")
if search in fruits:
    print(f" {search} found in tuple!")
else:
    print(f" {search} not found")

# Manual check using loop
found = False
for fruit in fruits:
    if fruit == "Cherry":
        found = True
        break
print(f"\nManual search for 'Cherry': {found}")

View the complete Tuples programs page.

Program Console Check element existence using 'in' operator Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.