Skip to content

Commit

Permalink
Merge pull request #89 from syk007/master
Browse files Browse the repository at this point in the history
Solution to #1
  • Loading branch information
the-vampiire authored Oct 15, 2018
2 parents fe08c32 + f218f7d commit 7145354
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions beginner/sum-of-all-numbers_deepak.py
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)

0 comments on commit 7145354

Please sign in to comment.