L
L
Likel0v2020-07-19 20:00:33
Python
Likel0v, 2020-07-19 20:00:33

Local variable referenced before assignment. Why?

Hello. I wrote the code, for some reason it writes an error that the variable was called before the

code created it

import collections
     answeres = {'fefewd':'cheburek', 'frgte':'cheburek'}
     ansc = collections.Counter()
      for value in answeres.values():
        ansc[value] += 1


Mistake:
UnboundLocalError: local variable 'ansc' referenced before assignment

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question