I am creating a list to store integers until the user hits 'N'
.
I need the code to sum all the integers in the list. However, I have to get an error in the code.
The error is
sumlst = sum(lst)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
How do I fix it?
Here's my code:
print("Enter an integer or N to exit:")
lst=[]
while True:
data = input()
if data == "N":
break
lst.append(data)
sortlst = sorted(lst)
sumlst = sum(lst)
print (sortlst)
print (sumlst)