dwblas, you said calculate it for each item, how would you actually do this in python?
computerfox, thanks for the solution is this the most effective way to get an average in Python?
User Profile
Collapse
-
Apologies if I ask the basic of questions as I am new to python.
How would you manually iterate through a list of lists? I would like to know any other built in functions/loops that would do the same thing as BVDET has shown. I'm just curious and want to learn that's all.Leave a comment:
-
working out the average within a nested list
Hi all,
another question....
I have a data structure which consists of a game players name and their scores, I have use lists within lists (2D):
results = [["Ben", 15, 18,25], ["George", 25, 35, 85], ["Evie", 2, 54, 84]]
What I want to do is work out the average for each player and then sort by the highest average score.
any idea?
... -
-
-
Yes kind of, but I want to display all the players results, starting with their highest....
Also can you explain briefly what the code does:
for i, item in enumerate(resul ts):
results[i] = [item[0], max(item[1:])]
is "item in enumerate" a default python statement?
the second line: results[i] = [item[0], max(item[1:])]
can you please explain this to me?Leave a comment:
-
Ways of Sorting 2D lists in Python
Hi all,
I am hoping you can help me.
I have a data structure which consists of a game players name and their scores, I have use lists within lists (2D):
results = [["Ben", 15, 18,25, 6, 9], ["George", 25, 35, 85, 12, 9], ["Evie", 2, 54, 84, 62,18]]
What I want to do is sort the list in alphabetical order with each players highest score.
I know how to sort by specifying...
No activity results to display
Show More
Leave a comment: