Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inp_data = [1, 2, 3, 4]
- def summ(cou):
- _ = 0
- for i in range(len(cou)): _ += cou[i]
- return _
- print(summ(inp_data))
- def summ_re(list_, summ=0, index=0):
- if index < len(list_):
- return summ_re(list_, summ+list_[index], index + 1)
- else:
- return summ
- print(summ_re(inp_data))
- def summ_wh(list_):
- summ = 0
- index = 0
- while index < len(list_):
- summ += list_[index]
- index += 1
- return summ
- print(summ_wh(inp_data))
Add Comment
Please, Sign In to add comment