def group_together(players, team):
coplayers = list(players)
players = []
players_team = []
num_players= len(coplayers)
no_groups = num_players // team
if num_players%team > 0:
no_groups += 1
c = 0
for i in range(no_groups):
players_team.append([])
for j in range(team):
if c < num_players:
players_team[i].append(coplayers[c])
c+=1
players = players_team
players = [456, 218, 67, 1, 101, 199]
group_together(players, 2)#nothing is returned
print(players)
Output:
[[456, 218], [67, 1], [101, 199]]
I'm trying to replace the players with the new groupings of it but when I run the code with the test code it does not print the new players in groups, but instead, it prints the old unmodified players.
Is there any way to fix this? If so I would be very grateful.