I have about a hundred numbers contained as strings in a list, and I need to add all of them together. To do this, I'm using the following code -
for item in listo:
sumo += int(item)
I'm getting a ValueError that says:
ValueError: invalid literal for int() with base 10: ''
I don't know what causes this particular error, rather than just the error that says that the string couldn't be converted to an int. Does anyone know what the problem is, and how to fix it?
EDIT - I found the error! I used the .split() method, and I accidentally added one too many period, creating an empty string.
sum(..)builtin with a generator, making it more declarative and a one-liner.