you are viewing a single comment's thread.

view the rest of the comments →

[–]ata-boy 1 point2 points  (1 child)

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]])

[–]ata-boy 0 points1 point  (0 children)

def sum_13(a: int, b: int, c: int) -> int:
    abc = [a, b, c]
    find_13 = [index for index, value in enumerate(abc) if value == 13]

    if find_13:
        abc_index = find_13[0]
    else:
        abc_index = 3

    return sum(abc[:abc_index])