logo CodeStepByStep logo

list_mystery_1_pop_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, 0, -1):
        if lis[i] < lis[i - 1]:
            element = lis[i]
            lis.pop(i)
            lis.insert(0, element)
    print(lis)
[2, 6, 1, 8]
[30, 20, 10, 60, 50, 40]
[-4, 16, 9, 1, 64, 25, 36, 4, 49]

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.