When to use a dectionary or a list

Lists retain order while dictionaries do not, hence time ordered data should only be used with lists. Dictionaries associate unique hashable keys with values, membership tests are also much faster with dictionaries (foo in bar). Lists allow for arithmetic operations much more readily than lists do (sum(), avg())

ML
Answered by Myles L. Python tutor

1533 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


Explain why creating a list of several instances of one element using something like my_list = [a] * 5 can result in strange behaviour


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences