Python Forum
arrays sum list unsupported operand type(s) for +=: 'int' and 'list'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
arrays sum list unsupported operand type(s) for +=: 'int' and 'list'
#4
It already does that:
def skaiciuoti(skaicius):
    global suma
    suma=0    
    for betkokszodis in skaicius:
        suma+=betkokszodis  
    return suma

first = [1, 2, 3, 4, 5]
second = [9, 3, 8, 6, 0, 12, 9]
print(skaiciuoti(first))
print(skaiciuoti(second))
output:
Output:
15 47
Reply


Messages In This Thread
RE: arrays sum list unsupported operand type(s) for +=: 'int' and 'list' - by Larz60+ - Oct-19-2019, 07:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to reverse a list and store in another list in python SuperNinja3I3 6 3,337 Aug-14-2022, 06:36 PM
Last Post: DeaD_EyE
Question Python - List - Int List sophi 8 2,605 Apr-21-2022, 07:55 PM
Last Post: sophi
  TypeError: unsupported operand type(s) for /: 'str' and 'int' enderfran2006 1 2,687 Oct-01-2020, 09:41 AM
Last Post: buran
  Check if a list exists in given list of lists Daniel94 2 2,263 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 2,721 Feb-19-2020, 08:51 AM
Last Post: undoredo
  have homework to add a list to a list using append. celtickodiak 2 2,046 Oct-11-2019, 12:35 PM
Last Post: ibreeden
  Search character from 2d list to 2d list AHK2019 3 2,528 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  I donr know how to search from 2d list to 2d list AHK2019 1 1,778 Sep-25-2019, 01:59 AM
Last Post: ichabod801
  Resolving unsupported operand type +=: 'int' and 'str' jedmond2 4 6,418 Sep-10-2019, 05:04 PM
Last Post: jedmond2
  sort a list alphabeticaly without changing the original list Holmen 5 4,250 Jan-27-2019, 01:49 PM
Last Post: Holmen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020