Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 2: Write a function with the following signature: List_mangler(list_in)

ID: 638409 • Letter: Q

Question

Question 2: Write a function with the following signature: List_mangler(list_in) The function assumes that list_in is a list of integers, and returns a new list containing transformed elements of list_in: If the element is even, it?s doubled. If the element is odd, it?s tripled. For example: > > > list_mangler([1, 2, 3, 4]) [3, 4, 9, 8] Present a short (no more than a couple of sentences) description of your solution approach. Then show your source code and the interactive shell output of three example runs.

Explanation / Answer

my_list = [1,2,3,4]
def list_mangler(list_in):
for i in range(len(my_list)):
if i % 2 == 0:
return i * i
else:
return i * i * i

print list_mangler

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote