Divide by 0 error

Wondering why I’m getting this error?

for category in android:
    total = 0
    len_category = 0
    for cat in android:
        category_app = cat[-4]
        if (category_app == cat):
            n_installs = float(app[-4])
            total += n_installs
            len_category += 1
avg_installs = total / len_category
print(category, ":", avg_installs)

ZeroDivisionErrorTraceback (most recent call last)
<ipython-input-45-9c41cf405913> in <module>()
     11             total += n_installs
     12             len_category += 1
---> 13 avg_installs = total / len_category
     14 print(category, ":", avg_installs)

Basics.ipynb (33 KB)

Hey, Elisha.

Note that the line len_category += 1 is inside an if-statement. It seems it never gets to this point. In other words, it seems like category_app == cat is never true.

Why is this the case? Note that category_app is an entry in category (which is a row in android) and cat is simply a row in android.

Does this help?