How can I make this code more simpler?
Task: . Complete the following function that returns true if a list lst contains duplicate elements; it returns false if all the elements in lst are unique. For example, the list [2, 3, 2, 1, 9] contains duplicates (2 appears more than once), but the list [2, 1, 0, 3, 8, 4] does not (none of the elements appear more than once). An empty list has no duplicates. The function does not affect the contents of the list. My code: def has_duplicates(lst): n = len(lst) count = 0 for i in range(n): same = i for j in range(i+1, n): if lst[same] == lst[j]: count += 1 if count == 0: return False else: return True def main(): a = [1,3,4,5,6,7,7,8] b = [1,2,3,4,5,6,8,7,9] print(has_duplicates(a)) print(has_duplicates(b)) main() Question: Is there a way that this code can be made better if we used binary search?