Dictionary Creation in Python
Level 394 keystrokes
This creates a dictionary and prints each key-value pair. Dictionaries store data as key-value pairs for fast lookup.
Python code
# Create a dictionary with curly braces {}# Keys and values are separated by colons1person = {"name": "Bob", "age": 30}# items() returns all key-value pairs as tuples# for loop unpacks each tuple into key and value2for key, value in person.items(): # Print each key and its corresponding value3 print(f"{key}: {value}")Output
name: Bob age: 30
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 8:× 4{× 3}× 3,× 2(× 2)× 2.× 1=× 1