python - Counting the number of times an action have been performed -


this sample code count number of times len(set_forbidden) > 0. now, if counts condition greater 3, have call openthedoor(uppumanga) , reset count zero. when try print count, getting count = 1, solve appreciated.

count = 0 def rydbergset(value,count): if len(set_forbidden) > 0:     count+=1     last_time = true     print "this count greater three-"+ str(count)     if (last_time == true) , (count>3):         openthedoor(uppumanga)         count = 0     else:         last_time = false return set_forbidden,count 

count == 0 does not assign 0 count variable, count = 0 job

please make sure assigning output count global count

(set_forbiden, count) = rydbergset(value, count)


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -