Use the following guidelines to manipulate lists.
- The output list is initially empty or some fixed sequence.
- Use
for x in xs:
to process each element of the input sequencexs
in turn. - Process the element
x
appropriately. - Append the element corresponding to
x
into the output list. - Once you've finished processing all elements, return the output list.
- Write a function
length
that takes a list and returns its length. - Write a function
max
that takes a list and returns the largest number in the list. - Write a function
first_negative
that takes a list and returns the first negative number in the list. If all numbers are non-negative, return 0.