compare two items x and y in a list [x,y]

Viewed 29

I want to compare items x and y in a list [x,y] and where x1 is bigger than x2 and y1 is smaller than y2, print "happy"; and if there are none in the entire list print "not happy".

I have done this so far but it is not helpful.

Can you point me where I've missed something without using a completely different method?

total = int(input())
totallist = []


for i in range(total):
    current = input().split()
    totallist.append(current)

for i in range (len(totallist)):

    for j in range (1,len(totallist)):

        if totallist[i][0] > totallist[j][0] and totallist[i][1] < totallist[j][1]:
            print("happy")
            end()

print("not happy")
0 Answers
Related