I am new to python and would like some help please.
Please refer to the screenshots in this post.
I have iniated a list and need to calculate the total average marks inputted by the user and display the total average marks.
The problem seems like the total average marks is being displayed as many times as there is an item in the list... So if there are 4 assignment marks given by the user. The terminal will display the same total average 4 times, when displaying it once is needed.
How do I just show the total average marks once, despite the list holding multiple items (numbers in this case)?
Typed Code Code Output as seen in Terminal
CodePudding user response:
There is no need to include a loop in your code. The sum and len functions take care of iterating over the list.
print(sum(marks_collection)/len(marks_collection))
Is enough.
As a side note, you can and should add the code to your question. Copying it into the question is enough but if you put ``` above and below it will format correctly as well.