More on Lists - Python meetup #6
2019 April 10
We covered all sorts of fun things about lists:
- lists passed as references
- upack a list, no matter how many elements
- some review of
enumerate()
and using afor
loop with anelse
- why would you want to? - how to use a
for
loop with more than one list at once (hint: usezip()
) - learning the pitfalls of appending or removing list elements inside a
for
loop (hint: don't do it!) - how to write a
filter
function correctly - how to write a
map
function correctly - list comprehensions as a quick way for writing things like maps and filters
- sorting lists, forward and reverse, and using our custom
key
function for the ultimate in sorting flexibility - tuples - which are a lot like lists, but immutable
As usual, there was more to cover than time, so next session we'll cover more complete examples. And then, on to....dictionaries, and what Webster never told you.
If you know lists, and something about dictionaries, check out this video for an explanation of how to create Python functions for variable number of arguments.