1

When I add lists to my list the result is list of correct length, but all the lists are the same, last list I added

code:

cycle_points = []
for i in range(games_per_cycle):
    points = game.game_cycle()
    print(points)
    cycle_points.append(points)
print(cycle_points)

When changing cycle_points = [] to cycle_points = [[] for n in range(games_per_cycle)] as suggested here, has no effect.

sample output:

[26.0, 26.0, 2.0, 22.0, 12.0]
[7.0, 23.0, 19.0, 1.0, 2.0]
[21.0, 28.0, 2.0, 12.0, 2.0]
[17.0, 26.0, 4.0, 25.0, 4.0]
[1.0, 30.0, 22.0, 15.0, 20.0]
[0.0, 19.0, 23.0, 6.0, 24.0]
[17.0, 15.0, 24.0, 2.0, 35.0]
[27.0, 5.0, 15.0, 17.0, 4.0]
[2.0, 24.0, 6.0, 26.0, 14.0]
[27.0, 11.0, 5.0, 12.0, 26.0]

[[27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0], [27.0, 11.0, 5.0, 12.0, 26.0]]

Full code here https://github.com/aoskarih/5wonders/blob/master/main.py if it helps.

0 Answers0