Help with my interval scheduling code

``````n=int(input("Enter number of jobs:"))
``````

M=[[]for i in range(n)]
for i in range(n):
x=0
s=input(“Enter”)
for t in s:
try:
x=(x*10)+int(t)
except ValueError:
if t==" ":
M[i].append(int(x))
x=0
if t==“p”:
x=int(x)+12
M[i].append(int(x))
M[i].append(0)
print(M)
#Enter1 6pm 6am
#Enter2 9pm 4am
#Enter3 3am 2pm
#Enter4 3am 2pm
def check(s1,f1,s2,f2):
a=[]
if s1>12 and f1<12:
for x in range(1,f1+1):
a.append(x)
for x in range(s1,25):
a.append(x)
else:
for x in range(s1,f1+1):
a.append(x)
b=[]
if s2>12 and f2<12:
for x in range(1,f2+1):
b.append(x)
for x in range(s2,25):
b.append(x)
else:
for x in range(s2,f2+1):
b.append(x)
if len(list(set(a)&set(b)))>0:
return 1
for i in range(n):
M[i][3]=0
for i in range(n-1):
for j in range(i+1,n):
if check(M[i][1],M[i][2],M[j][1],M[j][2]):
M[i][3]+=1
M[j][3]+=1
print(M)
for i in range(n-1):
for j in range(i+1,n):

``````    if M[i][3] > M[j][3]:
M[i],M[j]=M[j],M[i]
``````

print(M)
job=[]
for i in range(1,n):
for j in range(len(job)):
if check(M[i][1],M[i][2],M[j][1],M[j][2]):
pass
else:
job.append(M[i][0])

print(job)