1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Summing Python array values [closed]

Discussão em 'Python' iniciado por Stack, Outubro 24, 2024.

  1. Stack

    Stack Membro Participativo

    I am new to programming and trying to learn with python. I have this code and expecting to sum the values of an array but getting error.

    I have this code that I managed to write based on the things i learned online

    def sum_array(arr):

    total = 0
    for i in range(len(arr)):
    total += arr

    return total

    result = sum_array(1,2,3,4,5)
    print("Sum of array:", result)`


    I am at lost. Sorry if this is a beginners question

    Continue reading...

Compartilhe esta Página