1

My code is not printing the correct result for the test case "3, 12, 4, 10, 9 and 1." properly as it should result in "3+", yet it results in "3 +" (After reading the following instructions youll understand why). Was hoping I can get some insight as to what is wrong with my code.

Exercise: Fergusonball players are given a star rating based on the number of points that they score and the number of fouls that they commit. Specifically, they are awarded 5 stars for each point scored, and 3 stars are taken away for each foul committed. For every player, the number of points that they score is greater than the number of fouls that they commit.

Your job is to determine how many players on a team have a star rating greater than 40. You also need to determine if the team is considered a gold team which means that all the players have a star rating greater than 40.

Output the number of players that have a star rating greater than 40 , immediately followed by a plus sign if the team is considered a gold team.

My code thus far:

# Program for Fergusonball Ratings
total_number_players = int(input())
total_players_with_40_stars = 0
gold = '+'  # Gold star
for i in range(total_number_players):
    points = int(input())
    fouls = int(input())

    if points * 5 - fouls * 3 > 40:
        total_players_with_40_stars += 1

    if total_players_with_40_stars == total_number_players:
        print(total_players_with_40_stars, gold)
    else:
        print(total_players_with_40_stars)

Sample input is 3, 12, 4, 10, 9 and 1. And this should output 3+.

Yet my code prints out 3 +. (Space in between).

Any thoughts on how I can debug this successfully?

0 Answers0