Aaron Aaron - 2 months ago 26
Python Question

TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

I have a list that I am inserting numbers into when I try to add the numbers I get an error TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
Not really sure why. Here is my code

smallWindow = Window()
smallList = smallWindow.size(3)
print smallList

position = 0
sum = 0
for arg in sys.argv[1:]:
smallList.pop(position)
smallList.insert(0, int(arg))
print smallList
print smallWindow.max(smallList)
position+=1
if position == 3:
position = 0
sum = 0
for number in smallList:
sum += number

Answer

You have a None in smallList, and operand += won't work for this way - number must have to be an int, right now you are having:

int += None