From 9414b2574ab3518e73f27c2a801f2973021dc28c Mon Sep 17 00:00:00 2001 From: Presley Date: Sat, 13 Oct 2018 20:32:25 +0800 Subject: [PATCH] added sum_of_all_numbers solution --- beginner/sum_of_all_numbers_presleywong.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 beginner/sum_of_all_numbers_presleywong.py diff --git a/beginner/sum_of_all_numbers_presleywong.py b/beginner/sum_of_all_numbers_presleywong.py new file mode 100644 index 0000000..727255b --- /dev/null +++ b/beginner/sum_of_all_numbers_presleywong.py @@ -0,0 +1,13 @@ +def sum_all(input_list): + if type(input_list) is not list: + return + + total = 0 + input_list.sort() + start = input_list[0] + end = input_list[-1]+1 + + for n in range(start, end): + total += n + + return total