May-05-2019, 09:53 PM
Need help with the following:
Filter out all words that begin with P, B, or T.
Filter out all words that begin with P, B, or T.
colors = ["Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet", "Purple", "Pink", "Brown", "Teal", "Turquois", "Peach", "Beige"] #my response below- for position in range(len(colors)): color = colors[position] print(color) if color[0] in ["P", "B", "T"]: del colors[position] print(colors)
Output:Red
Orange
Yellow
Green
Blue #?
Violet
Purple #?
Brown #?
Turquois #?
Beige #?