Playing with cards(in stack)

i have written the code i have done dry run also each and every line i am not able to understand what is wrong with the code according to me my approch is correct.
Please help me to correct this code

Hey @mikki18
I see you’ve resolved your query and received 100 already
If there is nothing else you need help with please close this doubt