logo CodeStepByStep logo

collection_mystery6

Language/Type: Python collections list

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

def collection_mystery6(s):
    q = []
    s2 = []

    while len(s) != 0:
        if s[-1] % 2 == 0:
            q.append(s.pop())
        else:
            s2.append(s.pop())

    while len(q) != 0:
        s.append(q.pop(0))
    while len(s2) != 0:
        s.append(s2.pop())

    print(s)
[1, 2, 3, 4, 5, 6]
[42, 3, 12, 15, 9, 71, 88]
[65, 30, 10, 20, 45, 55, 6, 1]

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.