We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
i'm surprised this worked for you. it doesn't work. T[i] is not incremented properly. you are adding all the elements in range(3). if for example the input is '11 2 4 4 5 6 10 8 -12', you are 11 2 and 4 instead of 11 5 and 8. same thing with T[-i-1].
Also, T = list(map(int,input().split())) is inside the for loop. which means input has to be repeated in each iteration. you should move it outside the loop.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
i'm surprised this worked for you. it doesn't work.
T[i]
is not incremented properly. you are adding all the elements inrange(3)
. if for example the input is'11 2 4 4 5 6 10 8 -12'
, you are11 2 and 4
instead of11 5 and 8
. same thing withT[-i-1]
.Also,
T = list(map(int,input().split()))
is inside the for loop. which means input has to be repeated in each iteration. you should move it outside the loop.