-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a01dce
commit f218f7d
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def sum_all(l): | ||
try: | ||
if len(l) > 2 or len(l) is 0: | ||
raise ValueError('List must have only 2 number exactly') | ||
if l[0] == l[1]: | ||
return int(l[0]) + int(l[1]) | ||
else: | ||
if(l[0]<l[1]): | ||
return int(sum(range(l[0], l[1]+1))) | ||
else: | ||
return int(sum(range(l[1], l[0]+1))) | ||
except Exception as e: | ||
print(e.args) |