Skip to content

Commit b23d3d2

Browse files
author
Alfredo Miranda
committed
Completed lucky_sum.py
1 parent b949447 commit b23d3d2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

python/list-2/lucky_sum.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Given 3 int values, a b c, return their sum. However, if one of the values
2+
# is 13 then it does not count towards the sum and values to its right do not
3+
# count. So for example, if b is 13, then both b and c do not count.
4+
def lucky_sum(a, b, c):
5+
if a == 13:
6+
return 0
7+
8+
if b == 13:
9+
return a
10+
11+
if c == 13:
12+
return a + b
13+
14+
return a + b + c

0 commit comments

Comments
 (0)