Program Console Vignaankosh.com
Execution Panel
Console is empty.
Convert list to dictionary is an interactive PYTHON dry run visualizer from the Dict 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.
# Convert list to dictionary
# Method 1: List of pairs
pairs = [("name", "John"), ("age", 25), ("city", "Chicago")]
dict1 = dict(pairs)
print("List of pairs:", dict1)
# Method 2: Two lists using zip()
keys = ["id", "product", "price"]
values = [101, "Laptop", 1200]
dict2 = dict(zip(keys, values))
print("Using zip():", dict2)
# Method 3: List as keys (using comprehension)
fruits = ["apple", "banana", "cherry"]
dict3 = {fruit: len(fruit) for fruit in fruits}
print("List comprehension:", dict3)
# Method 4: List as keys with default value
names = ["Alice", "Bob", "Charlie"]
dict4 = dict.fromkeys(names, 0)
print("fromkeys() with default 0:", dict4)