From 0053b4d13f67063f59f952953cbb08af4fe28280 Mon Sep 17 00:00:00 2001 From: Chase choi Date: Sun, 31 May 2015 03:03:36 +0900 Subject: [PATCH] simplify multiple conditions --- cmds/gentest.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmds/gentest.py b/cmds/gentest.py index 19f8e48..8ba579e 100644 --- a/cmds/gentest.py +++ b/cmds/gentest.py @@ -60,13 +60,10 @@ def run(self): def ordinalth(n): last = n - n / 10 * 10 - if last == 1: - return '%dst' % n - elif last == 2: - return '%dnd' % n - elif last == 3: - return '%drd' % n - return '%dth' % n + ordinals = ['st', 'nd', 'rd', 'th'] + if last > 3: + last = 4 + return '%d%s' % (n, ordinals[last-1]) def generate_testsuite(url, name, locale):