Kodewick
Start learning →
Basic←→0 / 100

Skip the empty seats

#050BasicListsStrings4 min

In the cinema's seat list, an empty seat is an empty string "", or sometimes just spaces " ". Write taken_seats(seats) to return the names in the taken seats (with spaces trimmed off each name), in the same order.

Examples
taken_seats(["Lily", "", "Max", ""])→['Lily', 'Max']
taken_seats([" ", " Ivy ", ""])→['Ivy']
taken_seats(["", ""])→[]
main.py
def taken_seats(seats):
    names = []
    for seat in seats:
        name = seat.strip()
        # your code here: if name is not empty, add it to names
        pass
    return names
Ctrl + Enter runs too
Result

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