Having a list of numbers stored as strings how do I find their sum?
This is what I'm trying right now:
numbers = ['1', '3', '7']
result = sum(int(numbers))
but this gives me an error:
Traceback (most recent call last):
File "main.py", line 2, in <module>
result = sum(int(numbers))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
I understand that I cannot force the list to be a number, but I can't think of a fix.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…