Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sum_of_digits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def SumLoop(a):
a = a.split(' ')

return int(a[0])*int(a[1]) + int(a[2])
Comment on lines +1 to +4
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we un-indent function definition for SumLoop(a)?


def SumDig(a):
sum = 0
i = 0
while i < len(a):
sum = sum + int(a[i])
i+= 1
return str(sum)

b = input()
c = []
for i in range(b):
a = raw_input()
c.append(SumDig(str(SumLoop(a))))
x = ' '.join(c)
print x