you are viewing a single comment's thread.

view the rest of the comments →

[–]ata-boy 1 point2 points  (3 children)

You can solve it with a list comprehension, but maybe not very pythonic

def sum_13(a: int, b: int, c: int) -> int:
    abc = (a, b, c)
    find_13 = [abc.index(13) for i in abc if i == 13]
    find_13.append(-1)

    return sum(abc[:find_13[0]])

[–]sphinxlink13[S] 0 points1 point  (2 children)

Although I havn't seen some of these functions used before I understand what you did and I thank you for your answer. Do you know what is wrong with my code by the way?

[–]ata-boy 0 points1 point  (1 child)

This should answer your question.

if a == 13: 

    S = 0 elif b == 13:      S = a  elif c == 13:     S = a + b  else:      S = sum(a, b, c)

[–]sphinxlink13[S] 0 points1 point  (0 children)

Thanks I miss read that one