Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
2
Indexable
Never
cricket = []
football = []
badminton = []
lst3 = []
lst4 = []
lst5 = []
lst6 = []


for i in range(int(input("Enter number of students who play cricket"))):
    ele = int(input("enter roll number"))
    if ele not in cricket:
        cricket.append(ele)
    else:
        print("The roll number already exists")
        i=i-1

for i in range(int(input("Enter number of students who play badminton"))):
    ele = int(input("enter roll number"))
    if ele not in badminton:
        badminton.append(ele)
    else:
        print("The roll number already exists")
        i-=1
    

for i in range(int(input("Enter number of students who play football"))):
    ele = int(input("enter roll number"))
    if ele not in football:
        football.append(ele)
    else:
        print("The roll number already exists")
        i=i-1

def common(cricket, badminton):
    for i in cricket:
        if i in badminton:
            lst3.append(i)

    print("The list of students who play both cricket and badminton:", lst3)


def either(cricket, badminton):
    for i in cricket:
        if i not in badminton:
            lst4.append(i)
    for i in badminton:
        if i not in cricket:
            lst4.append(i)
    print("The list of students who play either cricket or badminton but not both:", lst4)


def footbal(cricket, badminton, football):
    for i in football:
        if i not in cricket:
            if i not in badminton:
                lst5.append(i)

    print("The list of students who play only football:", lst5)


def not_badminton(cricket, badminton, football):
    for i in cricket:
        if i in football:
            if i not in badminton:
                lst6.append(i)
    new = []
    for i in lst6:
        if i not in new:
            new.append(i)
    print("The list of students who play cricket and football but not badminton: ", new)


print("The list of students who play cricket:", cricket)
print("The list of students who play football", football)
print("The list of students who play badminton:", badminton)
common(cricket, badminton)
either(cricket, badminton)
footbal(cricket, badminton, football)
not_badminton(cricket, badminton, football)