0

can some one explain me the error so i can update the nested loop

NumberOfSSR = int(input("ENTER THE NUMBER OF TEAMS: ")) gamesSSR = ((NumberOfSSR - 1) * NumberOfSSR) // 2 print("YOUR TOURNAMENT HAVE ",gamesSSR, " MATCHES") NewListOfTeamsA = [] for a in range (0, NumberOfSSR): ListOfTeamsA = input("ENTER A TEAM: ") NewListOfTeamsA.append(ListOfTeamsA) print("THE TEAMS THAT HAVE REGISTERED FOR THE TOURNAMENT ARE:\n",NewListOfTeamsA) TeamSize = NumberOfSSR n = 1 for aaa in range(int(TeamSize)): print("GAMES FOR THE ROUND ", "{}".format(n), "\n") NewListOfTeamsA = (NewListOfTeamsA[len(NewListOfTeamsA) - TeamSize:len(NewListOfTeamsA)] + NewListOfTeamsA[1:len(NewListOfTeamsA) - TeamSize]) for aa in range(int(TeamSize)): print("Game", "{}:".format(n), NewListOfTeamsA[0], "vs. ", NewListOfTeamsA[aa + 1]) print("Game", "{}:".format(n), NewListOfTeamsA[0], "vs. ", NewListOfTeamsA[aa + 1]) IndexError: list index out of range

20th Nov 2019, 5:03 PM
Karl Nerpio
Karl Nerpio - avatar
1 Resposta
+ 1
use this instead: change NewListOfTeamsA[aa +1 ] to NewListOfTeamsA[aa] + 1 print("Game", "{}:".format(n), NewListOfTeamsA[aa], "vs. ", NewListOfTeamsA[aa] + 1) and add n = n + 1 to the first loop at the end to increment the GAMES FOR THE ROUND number.
20th Nov 2019, 6:32 PM
Bahhaⵣ
Bahhaⵣ - avatar