Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- q4
- def pop_random_element(self, the_list):
- """This method picks a random element from a list, removes that
- element from the list and returns the element.
- Note: the pop() function might be useful here
- """
- popped = the_list.pop(random.randint(0,len(the_list)-1))
- return(popped)
- --------------------------------------------------
- q5
- def append_unique(self, src, dst):
- """This method appends the elements of the src list to the dst list,
- but only if they are not already in the dst list. In other words, the
- dst list is increased by adding new elements from the src list.
- """
- for i in src:
- if i not in dst:
- dst.append(i)
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement