Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- def calc7(a):
- if (len(a) is 0):
- return -1
- lucky = False
- ret = 0
- for e in a:
- if lucky:
- ret += (e * 2)
- else:
- ret += e
- if e is 7:
- lucky = True
- else:
- lucky = False
- 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