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 ▸

Create an algorithm that can be used as a guessing game. Make sure to import random at the start.


How do I use format python code?


Implement a fibonacci function which calculates the nth number of the fibonacci sequence.


Write a program that computes the sum of all numbers up to a input number n