Skip to content

Instantly share code, notes, and snippets.

@alphanetEX
Created May 5, 2020
Embed
What would you like to do?
Dado el siguiente array: numeros = [15, 74,110,9,8,1,0,14,78,13,150,4] Mostrar la suma de todos los elementos pares contenidos en el arreglo.
def pair():
numbers = [15,74,110,9,8,1,0,14,78,13,150,4]
counter = 0
acumulator = 0
while counter <= len(numbers) -1:
if numbers[counter] % 2 == 0:
acumulator += numbers[counter]
counter += +1
return str(acumulator)
print("la suma de los elemtos pares es de :", pair())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment