Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calc7(vals):
- calk = 0
- luckky = 1
- for val in vals:
- calk += val * luckky
- if val == 7:
- luckky = 2
- else:
- luckky = 1
- if calk == 0:
- calk = -1
- return calk
- 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