Kodewick
Start learning →
Starter←→0 / 80

Movies we both want

#031StarterDictsLists3 min

You and a friend each wrote a list of movies to see this weekend, a and b. Write both_like(a, b) to find the movies on both lists and return them in alphabetical order, each only once. If there are none, return [].

Examples
both_like(["Up", "Coco", "Cars"], ["Coco", "Up", "Soul"])→['Coco', 'Up']
both_like(["Up"], [])→[]
main.py
def both_like(a, b):
    common = set()
    # your code here: turn both lists into sets and keep what is in both
    return sorted(common)
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.