Program Console Vignaankosh.com
Execution Panel
Console is empty.
Find common elements between two lists is an interactive PYTHON dry run visualizer from the Lists 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.
# Find common elements between two lists
list_a = [1, 2, 3, 4, 5, 6, 7]
list_b = [5, 6, 7, 8, 9, 10]
print("List A:", list_a)
print("List B:", list_b)
# Method 1: Using set intersection
common = list(set(list_a) & set(list_b))
print(f"Common elements: {common}")
# Method 2: Using list comprehension
common_comp = [x for x in list_a if x in list_b]
print(f"Using comprehension: {common_comp}")
# Method 3: Manual loop (preserves order)
common_manual = []
for item in list_a:
if item in list_b and item not in common_manual:
common_manual.append(item)
print(f"Manual loop: {common_manual}")