Codington
0 of 6 problems solved • 0%

Exercise prompt

Count Distinct Colors

Converting a list to a set removes duplicates. len counts how many items the set holds.

Example

A scanner sees the same parcel more than once.

scans = [12, 15, 12] parcels = set(scans) print(len(scans)) # 3 scans print(15 in parcels) # True print(parcels == {12, 15}) # True

A set represents membership. The extra scan of parcel 12 changes the number of scans but adds no member to the set.

Your task

Return the number of different color strings in colors. Comparison is case sensitive.

color_count(["red", "red", "Red"]) # 2