TIME LIMIT EXCEDED PLEASE HELP

i was submitting my code for the question although my code is doing exactly the same which was asked i am getting a time limit exceeded error which i cant figure out as i am new to C.P
t=input(“enter no of test cases”)
i=0
while i<t:
a=map(eval,raw_input(" ").split())
print a
l=[]
for i in range(0,len(a)):
for j in range(0,len(a)):
if(a[i]>a[j] and i!=j):
c=a[i]-a[j]
l.append©
elif(a[i]<a[j] and i!=j):
d=a[j]-a[i]
l.append(d)
i=i=1
l.sort()
print l[0]

this is my code please help

You are trying to find all the differences, but you just need the minimum difference. sort() is your friend.

If you solve the time limit issue, you will still get “wrong answer” though, because of all the unrequested output you are generating, including input prompts which are not needed here, and debugging print-out. Be sure to clear all that away before submitting.