Please note well: I have had to remove your solution code … again. Please see my Note in the previous post. Thank you for your future compliance to the Coursera course honor code.
As for your bug, see my post from just earlier today. It is the second from bottom.