I'm working on this assignment for school and got it almost nearly all done but I'm missing a really small but crucial piece.
So the full assignment is for the user to enter in some values for grades that a student gets into a list, then the user must be able to see the average of a particular subject or a printed out version of all the grades that all the students got for a subject.
My problem is that how do I put something to tell the user that there isn't any values for a particular subject when she selects to see the avg/all values for that subject. I'll show here what I got with a list that already has some values in, so there's no need to go through the whole process of putting them in
cijfers = [ [ 12345, 'wiskunde', 8.9], [ 12345,'elnet', 4.0], [12345, 'python', 8.9], [98761, 'wiskunde', 6.5], [98761, 'elnet', 7], [98761, 'python', 4.5], [20945, 'wiskunde', 5],[20945, 'elnet', 6.9], [20945, 'python', 4.5], [65489, 'wiskunde', 3.4], [65489, 'elnet', 6.7], [65489, 'python', 10]]
First one stands for student number, second one is the subject and third one is the grade that that particular student got.
so if i put this is to give me all the grades for the subject "wiskunde"
cijfers = [ [ 12345, 'wiskunde', 8.9], [ 12345,'elnet', 4.0], [12345, 'python', 8.9], [98761, 'wiskunde', 6.5], [98761, 'elnet', 7], [98761, 'python', 4.5], [20945, 'wiskunde', 5],[20945, 'elnet', 6.9], [20945, 'python', 4.5], [65489, 'wiskunde', 3.4], [65489, 'elnet', 6.7], [65489, 'python', 10]]
a = 0
print (' Tentamencijfers voor: ','Wiskunde', '\n', '========================================')
print (' studenten# | cijfer')
while (a<len(cijfers)):
if (cijfers [a][1] == 'wiskunde'):
print (' ',cijfers[a][0], ' ',cijfers[a][2])
a = a + 1
It gives me the follow as an output:
Tentamencijfers voor: Wiskunde #translates to exam grades for: Math
========================================
studenten# | cijfer
12345 8.9
98761 6.5
20945 5
65489 3.4
Which is it supposed to do, but let's say if there wasn't any values for "wiskunde" so the list would look like this:
cijfers = [ [ 12345,'elnet', 4.0], [12345, 'python', 8.9], [98761, 'elnet', 7], [98761, 'python', 4.5], [20945, 'elnet', 6.9], [20945, 'python', 4.5], [65489, 'elnet', 6.7], [65489, 'python', 10]]
It would give me this as an output:
Tentamencijfers voor: Wiskunde #translates to exam grades for: Math
========================================
studenten# | cijfer
I know that it shows just that little bit because i wrote the "print" function before the "while" but that's not my question.
So my question is how can I make it give me just a simple "There's no values put in for this particular subject"?