/* */

Tuesday 22 March 2011

Remove elements

numbers = [1,2,3,4,5,]
numbers [1,4] = []
numbers = [1,5]

This has similar effect to the delete statement and is related to replace. In this case you are simply replacing all the elements from position 1 up to (but not including) position 4 and replacing it with [] - an empty list. The items that survive in the list are those in position [0,4]. 

No comments:

Post a Comment