local variable referenced before assignment frequently occurring error -


hello i've done multiple python programs since started , error occurring quite short time , don't understand why there error or why changing random things program same gets rid of can please explain how "referenced before assignment" error occurs please.

here's code problem:

def compter(sequence, element):     comtpe=0     in sequence:         if element==sequence[i]:             compte+=1     return compte   compter([1,2,1,1], 1) 

please explain able rid of in future code thank :)

(i'musing python 2.7.6)


Comments