logo CodeStepByStep logo

list_mystery_2_mod2_insert

Language/Type: Python list mystery lists

Write the output produced when the following function is passed each of the following lists:

def mystery(lis):
    for i in range(len(lis) - 1, -1, -1):
        if i % 2 == 0:
            lis.append(lis[i])
        else:
            lis.insert(0, lis[i])
    print(lis)
[10, 20, 30]
[8, 2, 9, 7, 4]
[-1, 3, 28, 17, 9, 33]

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.