Help with a code

Help with a code
0.0 0


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:
    x = input("write the amount of money you used or send 'done': ")
    if x == 'done':
while pur_amount:
    subtotal += float(pur_amount.pop())

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

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