r/pythonhelp • • Sep 24 '20

can anyone help me explain what this python code mean?

Post image
4 Upvotes

2 comments sorted by

3

u/sentles Sep 24 '20

It's pretty simple. It asks the user for a number, n. It then creates a list of size n, containing other empty lists. In each of those lists, it appends a total of n numbers, given by the user.

Once this is done, it loops through every number, in every list contained in array. It multiplies each number by the index of its list in array and by the index of itself in its own list, then saves the result in the spot where the number previously was.

In the end, it just prints the results (array).

3

u/flaurosryuseigo Sep 24 '20

Oh dmn tht explains alot thanks man!