Skip to content

Commit

Permalink
Solution to issue 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Kushagra-0801 committed Oct 5, 2018
1 parent 29db125 commit 8c3b306
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions beginner/sum-earnings_Kushagra-0801.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Solution for Issue #8 (Sum Eanings Challenge)."""

try:
input_ = input()
required_nums = input_.count(',') + 1
history = list(map(int, input_.split(',')))
if len(history) != required_nums:
raise ValueError
balance = 0
for i in history:
balance += i
if balance < 0:
balance = 0
print(balance)
except ValueError:
print('0')

0 comments on commit 8c3b306

Please sign in to comment.