Created
March 24, 2015 18:30
-
-
Save gilrg18/528b6c01f8b54da601f9 to your computer and use it in GitHub Desktop.
Finding Threes
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
#Gilberto Rogel García a01630171 | |
def find_threes (list): | |
sum=0 | |
for x in range(0,len(list)): | |
if(list[x]%3==0): | |
#print(list[x]) | |
sum+=list[x] #sum=sum+list[x] | |
return (sum) | |
print("This program gives you the sum of all the numbers divisible by 3 in a list") | |
a=int(input("Give me a number to add to the list:")) | |
b=int(input("Give me a number to add to the list:")) | |
c=int(input("Give me a number to add to the list:")) | |
d=int(input("Give me a number to add to the list:")) | |
e=int(input("Give me a number to add to the list:")) | |
f=int(input("Give me a number to add to the list:")) | |
g=int(input("Give me a number to add to the list:")) | |
h=int(input("Give me a number to add to the list:")) | |
list=[a,b,c,d,e,f,g,h] | |
print("Your list:",list) | |
print("The sum of all the numbers divisible by 3 in your list is:",find_threes(list)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment