I know proposed is not a valid way to do things, however, in terms of speed, which will return quicker? Given a random list that we need to return Nth element:
try:
return L[N]
except:
return None
Or:
if len(L) < N:
return None
return L[N]
Aucun commentaire:
Enregistrer un commentaire