Skipping elements in a List Python

后端 未结 7 1652
隐瞒了意图╮
隐瞒了意图╮ 2021-01-17 13:28

I\'m new to programming and I\'m trying to do the codingbat.com problems to start. I came across this problem:

Given an array calculate the sum except when there is

相关标签:
7条回答
  • 2021-01-17 14:11

    You can use while loop to treat multiple 13.

    def sum13(lis):
        while pos(lis):
            if pos(lis) == len(lis) - 1:
                lis = lis[:pos(lis)]
            else:
                lis = lis[:pos(lis)]+lis[pos(lis)+1:]
    
        return sum(lis)
    
    0 讨论(0)
提交回复
热议问题