lundi 2 juillet 2018

counter using lambda in python

Can I implement a counter using a lambda function in python or some expression more pythonic?

here is my code:

counter = 0     
if 0 < arrival_time:
   counter += 1
else:
   pass

this is what I tried:

count_late = lambda x, arrival_time: x+=1 if 0 < arrival_time else pass
counter_late(counter, arrival_time)

the error: enter image description here

What am I missing or how can I improve this code?

Aucun commentaire:

Enregistrer un commentaire