Help with a code

im new to python and i started to learn last week. I have an assigment to do a code that you enter number(amount of money) and when you enter ‘done’ the loop breaks and than another loop starts of calculating it with .pop() function:
(the second part instruction)
create a subtotal variable = 0
create a while loop that runs while purchase_amount (is not empty)

inside the loop

pop() the last list value cast as a float type
add the float value to a subtotal variable
after exiting the loop print subtotal

my code is:

<p> pur_amount = []
x = float(input("write the amount of money you used or send 'done': "))
subtotal = 0
while True:
    pur_amount.append(x)
    print(pur_amount)
    x = input("write the amount of money you used or send 'done': ")
    if x == 'done':
        print(pur_amount)
        break        
while pur_amount:
    subtotal += float(pur_amount.pop())
    print(subtotal)<p>

can you tell me how i need to do the second part correctly?

edit:
i changed the code to the above and the only problem is that the output is a number with a lot of numbers after the dot i have no clue why

From the docs: Floating Point Arithmetic: Issues and Limitations

The easiest way to cut all the numbers out is print with formatting 2 decimal places

change print(subtotal) on the last line to print("%.2f" % subtotal)

This works