List:: Double - Index 1 2 3 4 2
List:: Double - Index 1 2 3 4 2
1.
Create a function named double_index that has two parameters named lst and index.
The function should return a new list where all elements are the same as in lst except for the
element at index, which should be double the value of the element at index of lst.
If index is not a valid index, the function should return the original list.
For example, the following code should return [1,2,6,4] because the element at index 2 has
been doubled:
double_index([1, 2, 3, 4], 2)
After writing your function, un-comment the call to the function that we’ve provided for you to
test your results.
1.
Create a function named remove_middle which has three parameters
named lst, start, and end.
The function should return a list where all elements in lst with an index
between start and end (inclusive) have been removed.
For example, the following code should return [4, 23, 42] because elements at
indices 1, 2, and 3 have been removed:
1.
Create a function named more_than_n that has three parameters named lst, item,
and n.
1.
Create a function named more_frequent_item that has three parameters
named lst, item1, and item2.
1.
Create a function called middle_element that has one parameter named lst.
If there are an odd number of elements in lst, the function should return the
middle element. If there are an even number of elements, the function should
return the average of the middle two elements.
1.
Write a function named append_sum that has one parameter named lst.
The function should add the last two elements of lst together and append the result to lst. It
should do this process three times and then return lst.
For example, if lst started as [1, 1, 2], the final result should be [1, 1, 2, 3, 5, 8].
1.
Write a function named larger_list that has two parameters
named lst1 and lst2.
The function should return the last element of the list that contains more
elements. If both lists are the same size, then return the last element of lst1.
1.
Create a function called every_three_nums that has one parameter named start.