In a throwback to CT days, you have to write one of the basic list functions.
Write a function named init that accepts a list L as argument. If the list is
non-empty and has size n, it should return the first n - 1 elements as a
list. If the list is empty, it should return None.
Note that if L has just one element, init(L) should return the empty list.
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
init([1, 2, 3]) -> [1, 2]
init([7]) -> []
init([]) -> None
Implement this function:
def init(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