Kodewick
Start learning →
Mini challenge←→0 / 100

Invited twice

#054Mini challengeListsLoops6 min

Several friends wrote the party guest list together, and some names went on more than once. Write invited_twice(guests) to return the repeated names, each name only once, in the order the repeats were found. No repeats means an empty list.

Examples
invited_twice(["Ana", "Ben", "Ana", "Cal"])→['Ana']
invited_twice(["Ivy", "Max", "Max", "Ivy", "Max"])→['Max', 'Ivy']
invited_twice(["Lu", "Kim"])→[]
main.py
def invited_twice(guests):
    seen = []
    repeated = []
    for name in guests:
        # your code here: seen before and not yet noted? note it
        seen.append(name)
    return repeated
Ctrl + Enter runs too
Result

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