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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.