Like the given list is l=[4,2,3,4,4,5]
Turn into l=[4,2,3,4,5]
I try to create an empty list to store the value but it is hard to compare if the two elements are equal with no loop
Like the given list is l=[4,2,3,4,4,5]
Turn into l=[4,2,3,4,5]
I try to create an empty list to store the value but it is hard to compare if the two elements are equal with no loop
to store every element only once is same like a set. you can use following code.
l=[2,3,4,4,5]
l=list(set(l))
l.sort()
it will give your expected output
You can use a dictionary which only keeps unique values as its key
l=[2,3,4,4,5]
list(dict.fromKeys(l))