I am 15 years old, and I am doing the task for school, I get to the part where I need the User to enter a list of integers, the program must then add the integers to the list together and return:
Total: $[sum of integers]
so far i have
cost = input("Enter the expenses: ")
cost = int(cost)
total = sum(i)
print("Total: $" + i)
but he keeps returning an error:
Traceback (most recent call last):
File "C:\Python33\Did I Spend Too Much.py", line 2, in <module>
cost = int(cost)
ValueError: invalid literal for int() with base 10: '10 15 9 5 7'
Where '10 15 9 5 7 'is the integers I entered when testing.
Any help with this would be greatly appreciated.
source
share