Python duplicate element finding function

Asked 2 years ago, Updated 2 years ago, 40 views

def list_L(A,B):
    d=[]
    for i in range(A):
        C=B.count(A[i])
        d.append(C)
        k=d.count(0)
        return True
    else:
        return False



A=[int(x) for x in input("enter list1 elements:").split()]
B=[int(x) for x in input("enter list2 elements:").split()]

if True:
    print ("overlapping")
else:
    print ("non-overlapping")

Even if it's an element that doesn't overlap, it keeps overlapping.

list function

2022-09-20 22:06

1 Answers

fori in range(A): not this, but fori in range(len(A): is intended, right?

Other than that, the code doesn't make sense.

if True: This only fits in the if condition, and it can never go with else.

You should study the basics.

If you're having a hard time, you're not good at programming, so do something else.


2022-09-20 22:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.