Kodewick
Start learning →
Starter←→0 / 80

Room at the bike rack?

#006StarterFunctionsStrings3 min

A row of bike spots is written as a string: B is a parked bike, . is an empty spot. Write rack_count(rack) to return both how many bikes and how many empty spots: (bikes, empty). An empty string gives (0, 0).

Examples
rack_count("BB.B.")→(3, 2)
rack_count("")→(0, 0)
main.py
def rack_count(rack):
    bikes = rack.count("B")
    empty = rack.count(".")
    # your code here: return bikes and empty together
    pass
Ctrl + Enter runs too
Result

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