lair of the dustbunny
Sunday, November 2, 2008
99 problems - python - 20
Remove the K'th element from a list.
def remove_at(lst, n):
return lst[:(n-1)] + lst[n:]
The simplest thing to do would be to just use .pop(), but I assuming that a non-destructive operation would be preferred in this case.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment