[Solved] Count value in dictionary


Keeping it simple, you could do something like this:

reading = 0
notReading = 0

for book in bookLogger:
    if book['Process'] == 'Reading':
        reading += 1
    elif book['Process'] == 'Not Reading':
        notReading += 1
        
print(f'Reading: {reading}')
print(f'Not Reading: {notReading}')

Alternatively, you could also use python’s list comprehension:

reading = sum(1 for book in bookLogger if book['Process'] == 'Reading')
notReading = sum(1 for book in bookLogger if book['Process'] == 'Not Reading')

print(f'Reading: {reading}')
print(f'Not Reading: {notReading}')

solved Count value in dictionary