Kodewick
Start learning →
Mini challenge←→0 / 80

Sticker swap

#038Mini challengeDictsLists6 min

You and a friend both collect animal stickers; mine and friend are what each of you has (with repeats). Write sticker_swap(mine, friend) to return (can_get, can_give): can_get is what the friend has and you don't, can_give is what you have and the friend doesn't, both as alphabetical lists.

Examples
sticker_swap(["cat", "dog", "dog"], ["dog", "fox"])→(['fox'], ['cat'])
sticker_swap([], ["owl"])→(['owl'], [])
main.py
def sticker_swap(mine, friend):
    mine_set = set(mine)
    friend_set = set(friend)
    # your code here: what the friend has and you don't, sorted, into can_get
    can_get = []
    # your code here: what you have and the friend doesn't, sorted, into can_give
    can_give = []
    return (can_get, can_give)
Ctrl + Enter runs too
Result

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