By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,668 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,668 IT Pros & Developers. It's quick & easy.

something wrong to uri 1478 solution

P: 1
I am new at python...I write this code. This is a uri problem and problem no 1478.Here the uri problem link:
My code:
Expand|Select|Wrap|Line Numbers
  1. while(1):
  2.     N=int(input())
  3.     if(N==0):
  4.         break
  6.     mainlist=[]
  7.     for i in range(0,N):
  8.         sublist=[]
  9.         for j in range(0,N):
  10.             sublist.append(9)
  11.         mainlist.append(sublist)
  13.     print(mainlist)
  15.     a=0
  16.     b=N
  17.     c=0
  18.     d=N-1
  19.     k=1
  20.     for j in range(0,N):
  21.         for i in range(a,b):
  22.             mainlist[c][i]=i+k
  23.             mainlist[i][c]=i+k
  24.             mainlist[d][N-1-i]=i+k
  25.             mainlist[N-1-i][d]=i+k
  27.         a+=1
  28.         b-=1
  29.         c+=1
  30.         d-=1
  31.         k-=1
  33.     for i in range(0,N):
  34.         for j in range(0,N-1):
  35.             print(" ",mainlist[i][j],end=" ")
  36.         print(" ",mainlist[i][N-1])
  37.     print("")
but when i submit this on uri...showing something error.and couldnt found this.Please anyone help me to fine the error of my code.
Jul 9 '18 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,365
Please use code tags when posting code or formatted data.

Did you try running your code to see if the output matches? Because it doesn't. Your code prints out extra stuff that it's not looking for. Specifically arrays filled with a bunch of 9s.
Jul 9 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.