Hollow Square Pattern

Program that displays hollow square pattern.

Solution in C    PYTHON
#include<stdio.h>
int main() {
  int n, i, j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(i==1 || i==n || j==1 || j==n)
        printf("*");
      else
        printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Input
5
Output
*****
*   *
*   *
*   *
*****