Counting ratings of 4 stars or more
Code review · Basic · §7.2, §7.3 Building up
These are the star ratings that five people left in their reviews. The code tries to print the names of the people who gave 4 stars or more and how many of them there are. It runs without errors, but the count is wrong. Fix it by moving just one line.
Code to fix
ratings = {"dami": 5, "taeo": 2, "yuna": 4,
"siwoo": 1, "nari": 4}
for name, score in ratings.items():
high = 0
if score >= 4:
high += 1
print(name)
print("High ratings:", high)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.