In a throwback to CT days, you have to write one of the basic list functions.
Write a function named last that accepts a list L as argument. It should
return the last element if the list is non-empty, and return None otherwise.
Note that L[-1] on its own is not enough: an empty list has no last element,
so that case has to be handled separately.
You do not have to accept input from the user or print anything to the console. You just have to write the function definition.
Example
last([10, 20, 30]) -> 30
last([]) -> None
Implement this function:
def last(L):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: L.
Input
[]
Output
None