'Error: Syntax: Missing comma or ) in argument list

I am trying to run the below code and getting the below error -

Error: Syntax: Missing comma or ) in argument list

Below is the complete code, I watned to create.

function tournamentWinner(competetions, results)
    teams = Dict()
    for i in range(1, length(results))
        if (results[i] == 1) && (competetions[i][0] not in teams)
            teams[competetions[i][0]] = 1
        elseif (results[i] == 1) && (competetions[i][0] in teams)
            teams[competetions[i][0]] += 1
        elseif (results[i] == 0) && (competetions[i][1] not in teams)
            teams[competetions[i][1]] = 1
        elseif (results[i] == 0) && (competetions[i][1] in teams)
            teams[competetions[i][1]] += 1
        end
    end
    return findmax(teams)[2]
end
competetions = [["HTML", "Java"],["Java", "Python"], ["Python", "HTML"],["C#", "Python"],["Java", "C#"],["C#", "HTML"]]
    
results = [0, 1, 1, 1, 0, 1]
tournamentWinner(competetions, results)


Solution 1:[1]

The below code worked for me, replaced 'in', 'not in' with 'haskey', '!haskey' for dictionary

function tournamentWinner(competetions, results)
    teams = Dict()
    for i in range(1, length(results))
        if (results[i] == 1) && !haskey(teams, competetions[i][1])
            teams[competetions[i][1]] = 1
        elseif (results[i] == 1) && haskey(teams, competetions[i][1])
            teams[competetions[i][1]] += 1
        elseif (results[i] == 0) && !haskey(teams, competetions[i][2])
            teams[competetions[i][2]] = 1
        elseif (results[i] == 0) && haskey(teams, competetions[i][2])
            teams[competetions[i][2]] += 1
        end
    end
    return findmax(teams)[2]
end

competetions = [["HTML", "Java"],["Java", "Python"], ["Python", "HTML"],["C#", "Python"],["Java", "C#"],["C#", "HTML"]]
    
results = [0, 1, 1, 1, 0, 1]
tournamentWinner(competetions, results)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harneet.Lamba