Why would I use dictionaries instead of a list?

A dictionary has several advantages over a list especially in python. Dictionarys have two parts to every entry the key and the value and these are stored as pairs. This can give you more flexibility when storing data. The primary advantage would be retrieving stored values as it is much simpler to search through a dictionary.If the data your trying to store is identifiable so the data can be attributed to name name or item this might be a preferable system. One example would be storing the age of school students. You could store the age and name as a value and key pair. This would allow you to sort the dictionary for a particular student and retrieve their age. To do this with lists you would require two lists to search through or a very complicated indexing systems.

Answered by Billy T. Python tutor

4674 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a program that can convert between celcius and farenheit temperature scales


Explain how you would write a python program that takes a rectangle and a point in a 2D space as command-line arguments and checks if they intersect.


Sales is real Customers is integer startmainprog input Sales input Customers if ((Sales > 500) OR ((Sales > 300) AND (Customers>9))) then output “Bonus Awarded” else output “No Bonus” end if end subroutine. Sales = 600 Customers = 9, answer:


Write a recursive function to return the nth Fibonacci number in Python


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences