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

Related Python Mentoring answers

All answers ▸

Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


Create an rock, paper, scissors game. The user should input one option, and the computer should play randomly.


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


How can you take a list of numbers and add 3 to every number in the list using only one line of code?