Checkpoint 8.6.1.
Rearrange the code statements to match the activecode window above. (This is an exercise in noticing where the indenting and outdenting happens, and where the return statement goes.)
len
function a lot already. If it werenβt part of Python, our lives as programmers would have been a lot harder.len
ourselves if it did not exist. Previously, we have used the accumlator pattern to count the number of lines in a file. Letβs use that same idea and just wrap it in a function definition. Weβll call it mylen
to distinguish it from the real len
which already exists. We actually could call it len, but that wouldnβt be a very good idea, because it would replace the original len function, and our implementation may not be a very good one.total
that takes a list of integers as input, and returns the total value of all those integers added together.count
that takes a list of numbers as input and returns a count of the number of elements in the list.