Q:

Write a Python program to check if the elements of a given list are unique or not

0

Write a Python program to check if the elements of a given list are unique or not.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def all_unique(test_list):
    if len(test_list) > len(set(test_list)):
        return False
    return True

nums1 = [1,2,4,6,8,2,1,4,10,12,14,12,16,17]
print ("Original list:")
print(nums1)
print("\nIs the said list contains all unique elements!")
print(all_unique(nums1)) 

nums2 = [2,4,6,8,10,12,14]
print ("\nOriginal list:")
print(nums2)
print("\nIs the said list contains all unique elements!")
print(all_unique(nums2))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now