Three branches packed into one line
Predict the output · Medium · §10.3, §10.7 [Pair coding with AI] "Make it Pythonic"
You asked an AI to label posts by their number of likes, and this is the one line it gave you. Predict the output without running the code.
Code
likes = [5, 0, 120, 100]
tags = ["popular" if n > 100 else "normal" if n > 0 else "none" for n in likes]
print(tags)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.