Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. def product(a: list):
  2.     result = 0
  3.     for indx, t in enumerate(a):
  4.         if indx > 0:
  5.             result *= t
  6.         else:
  7.             result += t
  8.     return result
  9. print(product([1, 2, 3]))
  10. print(product([4, 5, 6, 7]))
  11. print(product([10]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement