What's wrong in this code of inverse pyramid question

This code for inverted pyramid pattern does not work as intended, what can be the problem??
this is the code:

code link