InterviewSolution
Saved Bookmarks
| 1. |
WAP (Write a program) which takes a sequence of numbers and check if all numbers are unique. |
|
Answer» You can do this by converting the list to SET by USING set() method and comparing the length of this set with the length of the original list. If FOUND EQUAL, return TRUE. def check_distinct(data_list): if len(data_list) == len(set(data_list)): return True else: return False;print(check_distinct([1,6,5,8])) #Prints Trueprint(check_distinct([2,2,5,5,7,8])) #Prints False |
|