Please change it to- if listofmarks[i]==00:   After the changes its working as absent student will obviously have 0 marks in the test