I am trying to create a function to count each time the string 'online' appears as a value in a dictionary.
For example, inputting the following dictionary into the function should yield 2, but I only get 0.
statuses = {
"Alice": "online",
"Bob": "offline",
"Eve": "online",}
The following is what I've come up with so far. This function only returns 0. How could I get the function to return the correct count? Why is it returning 0?
def online_count(dict_a):
count = 0
for i in dict_a:
if dict_a[i] == "online":
count + 1
return count