Fixing a condition to fit its purpose

Code review · Medium · §5.5, §5.6, §6.5 Truthy and falsy

The code should give True if there are 50 or more likes and the tag list has at least one of the tags "data" or "survey", and False otherwise. Fix the line that calculates selected. Use parentheses to group the two membership checks so that they are checked before and.

Code to fix

likes = 50
tags = ["news"]
selected = likes >= 50 and "data" or "survey" in tags
print(selected)

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.