Daily Coding Challenge - Battle of Words

Tell us what’s happening:

I’m not able to pass the last check, because it asks the code to return “Draw”, but I’m not able to.

Your code so far

def points(arg):
    if arg.islower():
        return ord(arg.lower()) - 96
    elif arg.isupper():
        return (ord(arg.lower()) - 96) * 2
    else:
        return Exception
def battle(our_team, opponent):
    my_points = 0
    opponent_points = 0
    for i in our_team.replace(" ", ""):
        my_points += points(i)
    for i in opponent.replace(" ", ""):
        opponent_points += points(i)

    if my_points == opponent_points:
        return "Draw"
    elif my_points > opponent_points:
        return "We win"
    elif my_points < opponent_points:
        return "We lose"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0

Challenge Information:

Daily Coding Challenge - Battle of Words
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-10-12

Welcome to the forum @pedroramos.lima0

To help you debug, what points does the points function generate?

Happy coding

“We win”, because my_points = 310 and opponent_points = 227.

A word wins if its value is greater than the opposing word’s value.

The winning point is for a winning word, not for the total number of points for each sentence.

  • there is a clause about checking “word” against “word” and based on that you have to decide on how many words are higher in points in one team vs another, you will have to take that into consideration
  • i initially went with similar to yours, with total points instead of per word based comparisons!!

hope that was helpful, happy coding :slight_smile:

1 Like