Print the given star pattern. Which method is used to add a list to another list? Write a Python code to find duplicate elements in a list.
Anonymous
rows = 5 for i in range(1, rows+1): print("*" * i) list1 = [1, 2, 3] list2 = [4, 5, 6] list1.extend(list2) print(list1) list1 = [1, 2, 3, 4, 2, 5, 3, 6] duplicates = [] for i in list1: if list1.count(i) > 1 and i not in duplicates: duplicates.append(i) print("Duplicate elements:", duplicates)
Check out your Company Bowl for anonymous work chats.