diff --git a/beginner/sum-of-all-numbers-rosdyana.py b/beginner/sum-of-all-numbers-rosdyana.py index 0eca840..8c8da4c 100644 --- a/beginner/sum-of-all-numbers-rosdyana.py +++ b/beginner/sum-of-all-numbers-rosdyana.py @@ -10,4 +10,4 @@ def sum_all(list_input): # start to sum it for i in range(firstnum, secondnum+1): result += i - return result \ No newline at end of file + return result diff --git a/beginner/sum_of_all_numbers_mikelane.py b/beginner/sum_of_all_numbers_mikelane.py new file mode 100644 index 0000000..5b6178c --- /dev/null +++ b/beginner/sum_of_all_numbers_mikelane.py @@ -0,0 +1,18 @@ +from typing import List + + +def sum_all(list_input: List[int]) -> int: + """Challenge + + - Write a function called sum_all() that takes a list of two numbers. + - Return the sum of those two numbers plus the sum of all the numbers between them. + + Notes: + The lowest number will not always come first + + >>> sum_all([1, 4]) + 10 + >>> sum_all([4, 1]) + 10 + """ + return sum(range(min(list_input), max(list_input) + 1))