Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # #!/usr/bin/python
- #
- # By dvdjaco
- # Exercise 8.1
- #
- # 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.
- def chop(l):
- del l[0]
- del l[len(l)-1]
- return None
- def middle(l):
- return l[1:len(l)-1]
- l = [10,11,12,13,14]
- print l
- chop(l)
- print l
- l = [10,11,12,13,14]
- print l
- print middle(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement