logo CodeStepByStep logo

set_mystery1

Language/Type: Python collections dict set

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

def mystery(names):
    result = set()
    for element in names:
        if element < names[0]:
            result.add(element)
        else:
            result.clear()
    print(result)

Though sets store their contents in unpredictable order, for this problem, write the values sorted in alphabetical order. Write your answer in this format: {'value', 'value', 'value'}

['marty', 'stuart', 'helene', 'jessica', 'amanda']
['sara', 'allison', 'janette', 'zack', 'riley']
['zorah', 'alex', 'tyler', 'roy', 'roy', 'charlie', 'phil', 'charlie', 'tyler']

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.