You could do list comprehension to create a list of all the indicies that match and get the length of that, so something like len([index for index in count_num if 4 < count_num[index] < 10])
the len() part should be self-explanatory, just getting the length of whatever's passed in but the part inside is your list comprehension:
[index for index in count_num if 4 < count_num[index] < 10]
or basically create a list of all index values where count_num[index] is between 4 and 10.
That last conditional there are a few ways you can do it, either what I put, or if you didn't think that, count_num[index] < 4 and count_num[index] < 10
or even since it's a range do something like count-num[index] in range(4,10)
with the way you're doing it though you'll run into several errors.
First, the reason it's failing is because doing for index, value in count_num
, the in part uses an iterator that's returning only the keys and so it's failing. you'd need to do for index, value in count_num.items()
After you fix that, your index_numb += 1
is indented wrong so it's not considered within the scope of your if statement so you'll get an error with that.
After you fix that additionally, you're doing index_numb += 1
but index_numb is a list so adding 1 to it makes no sense. You probably meant to do index_numb = 0
then your index_numb += 1
will increment.