This program defines a list 'a' which contains integers. It then prints the original list. It then defines a variable 'K' with a value of 2. The program then creates an empty list called 'res'. It then iterates over each element 'i' in the list 'a' using a for loop. For each iteration, it counts the frequency of the element 'i' in the list 'a' using the count() method. If the frequency of the element is greater than 'K' and the element is not in the list 'res', it is added to the list 'res'. Finally, the program prints the list 'res', which contains the elements in the original list 'a' that have a frequency greater than 'K'.
a = [4, 6, 4, 3, 3, 4, 3, 7, 8, 8] print("Original list : " + str(a)) K = 2 res = [] for i in a: freq = a.count(i) if freq > K and i not in res: res.append(i) print("The Required Elements : " + str(res))
Original list : [4, 6, 4, 3, 3, 4, 3, 7, 8, 8] The Required Elements : [4, 3]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions