I’m writing this post to summarize all the mistakes I’ve been making for several times. You know what? They just don’t come into my mind!
1. Don’t create mutable objects by *
❌
sums = [[0] * number_of_experiments] * number_of_participants
⭕
sums = [[0] * number_of_experiments for _ in range(number_of_participants)]
When multiply inner lists by *, only the reference of that single inner list will be copied multiple times instead of creating new lists.