Unit 3 Task 4 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 4: Marks in a list

← Back to task


One possible program:

marks = []

while True:
    mark = float(input("Mark (-1 to finish): "))
    if mark == -1:
        break
    marks.append(mark)

if len(marks) == 0:
    print("No marks entered.")
else:
    print("Count:", len(marks))
    print("Average:", sum(marks) / len(marks))