def question():
purchase_amounts = []
while True:
user = input("enter your prices: ")
purchase_amounts.append(user)
if user == "done":
print(purchase_amounts)
return add(purchase_amounts)
def add(array):
ans = 0
for num in array[:-1]:
ans += int(num)
return ans
print(question())
Close! To answer your first question you are adding to a list instead of appending thus you are adding individual characters as strings.
I rewrote your question with two functions one main function then one helper. So while True is basically an infinite loop until we return. You keep asking the user input questions in the loop and then once you find done you call the add() function. From here you sum the array sliced removed the last index which is not inclusive in the slice.