I have list with file paths (as string) from different directories; Im trying to remove duplicate file name (it can be even from different directory). Now I loop through whole list, make a dictionary to remove the duplicates. Is there any other efficient way?
            Asked
            
        
        
            Active
            
        
            Viewed 35 times
        
    1 Answers
-1
            
            
        try using set()
unique_list = set(list1)
or if you want list returned
unique_list = list(set(list1))
 
    
    
        Kazi Abu Jafor Jaber
        
- 161
- 1
- 10
- 
                    I want to compare only the file name not the entire path ... So this might not work. – syv Sep 11 '19 at 19:26
- 
                    @syv then post some examples of these – SuperStew Sep 11 '19 at 19:32
- 
                    I have 3 entries {mypath/xyz.txt, mypath/log/xyz.txt, mypath/abc.txt} I would like to remove second entry as it has same file name "xyz.txt" irrespective of path. Result Im expecting is {mypath/xyz.txt, mypath/abc.txt} – syv Sep 11 '19 at 19:35
