What causes `.find()` to return -1?

Python? No. But you can still see what the involved parts are so long as I don’t put too many things into it.

Take some things, partition on whether any element is equal to ‘&’
Take some things, split them on ‘&’, flatten the results (concat)

The operation you’d want here is one exposed by python’s in operator. What exactly it does depends on the type of value you’re using it with, but generally means “contains” or “has”, so

pairs = [color for color in colors if '&' in color]
singles = [color for color in colors if '&' not in color]

python, this time.

2 Likes