Created
May 2, 2017 05:10
-
-
Save ehedaoo/294dfc6acbd5565134826b3e385aba01 to your computer and use it in GitHub Desktop.
Write a Python program to sum all the items in a list.
using function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a Python program to sum all the items in a list. | |
# use function | |
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
def sum_list(a): | |
sum_test = 0 | |
for i in a: | |
sum_test += i | |
return sum_test | |
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
print(sum_list(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment