Python: Making a Dictionary

Post Reply
User avatar
Jason
Site Admin
Posts: 809
Joined: Tue Jul 01, 2025 10:13 am

Dictionaries are the same thing as associative arrays in other languages. They consist of key and value pairs and there can't be duplicate keys.

Code: Select all

dictionary_of_car_owners = {"Amber" : "Ford", "Joey" : "Chevy", "Jerry" : "Toyota", "Jane" : "Hyundai"}

print(dictionary_of_car_owners)

# Below is another way to make one.

dictionary_of_basketball_players = dict(Amber = "Tigers", Joey = "Bears", Jane = "Lions")

print(dictionary_of_basketball_players)


 

POSTREACT(ions) SUMMARY

Post Reply