We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def sumArray(ar = []):
n = int(input("Cuantos numeros deseas que contenga la lista?: "))
for i in range(n):
if n < 0 or n >=1000:
print("Número no valido, ingresa valores entre 0 - 1000")
n = int(input("Cuantos numeros deseas que contenga la lista?: "))
else:
for j in range(n):
elements = int(input("Ingresa los elementos de la lista: "))
ar.append(elements)
sum_list = sum(ar,0)
return sum_list
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Array Sum
You are viewing a single comment's thread. Return to all comments →
What's wrong in my code?
def sumArray(ar = []): n = int(input("Cuantos numeros deseas que contenga la lista?: "))