I am trying to add all of the negative integers in a user input list, but the function always returns 0 as the answer. It works if I include the list as part of the function, but not when its user input. The code I have is:
def sumNegativeInts(userList):
userList = []
sum = 0
for i in userList:
if i < 0:
sum = sum + i
return sum
userList = input("Enter a list of +/- integers: ")
print(sumNegativeInts(userList))