#208: Working With Lists and Dictionaries
I had to do a lot of work with lists and dictionaries to solve the puzzles for Advent of Code. Here is my little cheat sheet for these two basic data structures from which you could also benefit.
Length of a list
Copy a list
Append at the end of a list
Append at the beginning of a list
Reverse a list (in place)
Create a reversed copy of a list
Sum up all entries in a list
Multiply all entries in a list
Find the least common multiple
Get maximum and minimum of entries in a list
Sort a list (in place)
Sort a copy of the list
Sort a list by a property of the entries
Turn a string into a list of characters
Turn a list into a string
Iterate through a list
Iterate through a list with an index
Get the largest value of a dictionary
Get the largest key of a dictionary
Get the key for the largest value in a dictionary
Next
This cheat sheet may be of help for your next attempt with Advent of Code of when you need to do some work with lists and dictionaries. Next week we explore defaultdict, one more thing about dictionaries and lists that can make your code simpler.