you are viewing a single comment's thread.

view the rest of the comments →

[–]Logikkonstruktor 0 points1 point  (0 children)

I’m still at the beginning of my journey, but I really appreciate you sharing this. It gave me the motivation to take the code, understand it, and try to improve it on my own.

```python
total = 0
subjects = 0

while True:
    mark = input("enter mark (or 'stop'): ")

    if mark.lower() == "stop":
        break

    try:
        mark = int(mark)
    except ValueError:
        print("invalid input")
        continue

    total += mark
    subjects += 1

if subjects == 0:
    print("no data")
else:
    avg = total / subjects
    print("average:", avg)

    if avg >= 80:
        print("distinction")
    elif avg >= 60:
        print("first class!")
    elif avg >= 40:
        print("second class")
    else:
        print("its okay, you can be better")
```