How can i write a program to check that all elements in a list are unique. I have a list that is entered by the user and i would like the program to check that the elements are unique, if they are, say list=[1,2,3,4,5], then the program continues. If not, say list=[1,2,3,4,5,5,5], then the user must reenter the list. Thankyou
Asked
Active
Viewed 280 times
1 Answers
2
This link has explained in details https://www.geeksforgeeks.org/python-check-if-list-contains-all-unique-elements/
# to check all unique list elements
flag = len(set(test_list)) == len(test_list)

Hassan
- 118
- 6