Q63.Let `medalDict` be a dictionary with player name as key mapped to the list of medals associated with the player from the Olympics dataset. `repeatMedals(medalDict)` should return the list of players who have won at least one type of medal more than once. The code may have mistakes. Identify all such mistakes, if any.
```
procedure repeatMedals(medalDict)
repeatPlayers = []
foreach player in keys(medalDict) {
tempDict = {}
foreach medal in medalDict[player] {
tempDict[medal] = True
}
if(length(keys(tempDict)) == length(medalDict[player])) {
repeatPlayers = repeatPlayers ++ [player]
}
}
return(repeatPlayers)
End repeatMedals
```
Save
Check
Details
Q63
20 Nov 2022
Q63.Let `medalDict` be a dictionary with player name as key mapped to the list of medals associated with the player from the Olympics dataset. `repeatMedals(medalDict)` should return the list of players who have won at least one type of medal more than once. The code may have mistakes. Identify all such mistakes, if any.
```
procedure repeatMedals(medalDict)
repeatPlayers = []
foreach player in keys(medalDict) {
tempDict = {}
foreach medal in medalDict[player] {
tempDict[medal] = True
}
if(length(keys(tempDict)) == length(medalDict[player])) {
repeatPlayers = repeatPlayers ++ [player]
}
}
return(repeatPlayers)
End repeatMedals
```