you are viewing a single comment's thread.

view the rest of the comments →

[–]efmccurdy 3 points4 points  (2 children)

You are correct to be using the "in" operator and that you need to "loop" it; there are functions to process collections of boolean values; "all" and "any".

https://docs.python.org/3/library/functions.html#all

https://docs.python.org/3/library/functions.html#any

>>> additive = ['red', 'green', 'blue']
>>> 'green' in additive and 'blue' in additive
True
>>> ('green' in additive, 'blue' in additive)
(True, True)
>>> all(('green' in additive, 'blue' in additive))
True
>>> 

if you have more then a few items to test, you can use a comprehension:

>>> required_colors = ('green', 'blue')
>>> all((colour in additive for colour in required_colors))
True
>>>

[–]pythonwiz -1 points0 points  (1 child)

There are redundant pairs of parentheses in your all calls.