From f0568d642ee6bcebbba330452e09e76d3c73e150 Mon Sep 17 00:00:00 2001 From: Du YuanChao Date: Tue, 8 Oct 2019 16:24:01 +0800 Subject: [PATCH] less code (#1292) --- maths/abs.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/maths/abs.py b/maths/abs.py index 4d15ee6e8..7509c5c20 100644 --- a/maths/abs.py +++ b/maths/abs.py @@ -10,11 +10,7 @@ def abs_val(num): >>abs_val(0) 0 """ - if num < 0: - return -num - - # Returns if number is not < 0 - return num + return -num if num < 0 else num def main():