From 8ee914a867a8df6f57b34a1f9720eaaf55084841 Mon Sep 17 00:00:00 2001 From: shreddd Date: Wed, 3 Jul 2013 21:21:19 +1200 Subject: [PATCH] fix mean_sightings --- python/mean_sightings-full.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/mean_sightings-full.py b/python/mean_sightings-full.py index a76c416..55c5148 100755 --- a/python/mean_sightings-full.py +++ b/python/mean_sightings-full.py @@ -40,14 +40,17 @@ def get_sightings_loop(filename, focusanimal): focusanimal = focusanimal.capitalize() # Loop through all records, countings recs and animals - totalrecs = 0 - totalcount = 0 + totalrecs = 0. + totalcount = 0. for rec in tab: if rec['animal'] == focusanimal: totalrecs += 1 totalcount += rec['count'] - meancount = totalcount/totalrecs + if totalrecs==0: + meancount = 0 + else: + meancount = totalcount/totalrecs # Return num of records and animals seen return totalrecs, meancount -- 2.26.2