A default value you cannot tell apart from 0
Code review · Medium · §4.2, §4.7 [Pair coding with AI] Asking for dictionary code
You asked an AI for code that looks up the number of likes by post ID and prints it. For an ID that does not exist, it should print No such post. The code runs without errors, but it prints 0 for the missing ID p9, so you cannot tell it apart from p2, which has 0 likes. Fix just one place.
Code to fix
likes = {"p1": 12, "p2": 0, "p3": 7}
post = "p9"
print(likes.get(post, 0))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.