Doubt in pattern 20

I have written a code for pattern 20. But it is showing a small error. Please explain why.

The error appears in the first and last line.

@pssharma1410 Please reply to my doubt.

@saijaltripathy_e79096f8f1ec20e3 Sorry for delay in reply. add a if statement for first row and last row.
in the if condition print a single star and use continue; keyword so that no code after this if will be executed.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Can you please write the whole code of this pattern? I am not getting it.

What is the problem in my code? Please tell the particular part of the code where I have done mistake.
@pssharma1410