From b755f8e6f723ea82fe0c10b0ae45eb5839315bc8 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 9 Mar 2017 02:52:33 -0600 Subject: [PATCH] count.py now works in py3 and py2 Figured compatibility is good --- count.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/count.py b/count.py index a149b8f..60f1ed1 100644 --- a/count.py +++ b/count.py @@ -21,8 +21,8 @@ for problem_name in problem_names: # print traceback.format_exc() problems.sort(key=lambda p: p.get("value"), reverse=True) -print "Grand Total: %d" % len(problems) -print "Category Breakdown:" +print("Grand Total: %d" % len(problems)) +print("Category Breakdown:") maxtitle = max(map(lambda p: len(p.get("title")), problems)) + 3 maxauthor = max(map(lambda p: len(p.get("author")), problems)) + 3 @@ -30,7 +30,7 @@ maxauthor = max(map(lambda p: len(p.get("author")), problems)) + 3 c = Counter(map(lambda p: p.get("category", ""), problems)) categories = sorted(c.items(), key=lambda c: c[1], reverse=True) for category, count in categories: - print " %s: %s" % (category, count) + print(" %s: %s" % (category, count)) for problem in problems: if problem.get("category") != category: continue - print " %s %s %sp" % (problem.get("title") + " " * (maxtitle - len(problem.get("title"))), problem.get("author") + " " * (maxauthor - len(problem.get("author"))), problem.get("value")) + print(" %s %s %sp" % (problem.get("title") + " " * (maxtitle - len(problem.get("title"))), problem.get("author") + " " * (maxauthor - len(problem.get("author"))), problem.get("value")))