Reference no: EM132275458
Combine List with Mutation
Build the function, list_combine, that takes in one list and modify the list so that it is left with one item that's the +combination of every single item in the list. method lst.pop() useful. Use + to combine items in the list.
>>> a = [1,4,5,6,7,8]
>>> a.pop() # If no argument is put in, the last item in the list is popped off.
8 # The pop method returns the item popped off (aka taken off the list)
>>> a [1, 4, 5, 6, 7]
>>>a.pop (2) # Pop off the third item in the list.
5
>>> a
[1, 4, 6, 7]
def list_combine(lst):
"""Write a function that combines all the items in the list into one item and put it as the only item in the list.
>>> pokemon = [4, 5, 3, 2, 1, 6]
>>> list_combine(pokemon)
>>> pokemon
[21]
>>> alphabet = ["a", "b", "c", "d", "e"]
>>> list_combine(alphabet)
>>> alphabet
['abcde']
"""
"*** YOUR CODE HERE ***"