Use like this way, it is basically going through key:value
pair of counters
, you used key
without getting it. Also use num_values
instead num_keys
as there is nothing named num_keys
in your code, you can use the value
rather than again accessing by counters[key]
. Another thing is you may be need to declare scores
outside the loop.
scores = 0
for key, value in counters.items():
# scores = 0
if value <= num_values:
scores += 1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…