August 16th, 2013, 11:58 AM
Ebook question help needed
im having trouble with this exercise.
Exercise 10.2 Write a function called chop that takes a list and modifies it, removing the first and
last elements, and returns None.
Then write a function called middle that takes a list and returns a new list that contains all but the
first and last elements.
I think I can do the second part, I came up with-
The first part has me stumped tho, I came up with this-
It returns None but it doesn't look right and im not sure that this is what the question is asking for. Some advice would be appreciated.
August 16th, 2013, 01:29 PM
Useful trick: Index from the right end
>>> def chop(t):
del t, t[-1]
# del t
# del t[-1]
>>> def middle(t):
Comments on this post
[/code] are essential for python code and Makefiles!