samedi 21 mars 2015

How can I make a Python function examine every element of a list?


I was ordered to build a Bulean Function that takes a list of numbers and execute "True" if the list is a proper grade list(i.e every number is between 0 to 100) and "False" otherwise. I however encounter Error, caused, I believe by my not very thorough acquaintance with the program. The reason why I ask here is that I mostly learn by doing.


I tried few scripts. This is one of them:



def IsValidGradeList(I): for x in range(0,len(I)+1): if I[x] not in range (0,101): return False else: continue return True



As I see, the code won't look the way it does in the scripter. How can I attend it? I would really appreciate your help.





Aucun commentaire:

Enregistrer un commentaire