Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calc7(arr):
- if len(arr) == 0:
- return -1
- else:
- is_7 = False
- ret = 0
- for i in arr:
- if is_7:
- ret += i * 2
- is_7 = False
- else:
- ret += i
- if i == 7:
- is_7 = True
- return ret
- print(calc7([1,2]))
- print(calc7([3,7]))
- print(calc7([7,5,6]))
- print(calc7([7,9,7,9,7,9]))
- print(calc7([]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement