Can you help fix my code?

please check and tell me why it’s wrong

i would follow the advise from this comment:

# Uncomment these function calls to test your  function:

uncommenting the function calls shows you output and can be a massive help in debugging.

Then checking the output against your program, you will see that the loop in your function only makes a single iteration