IvaSerge

clean_list_save_structure

Sep 20th, 2021
963
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. def clean_list(_list):
  3.     outlist = list()
  4.     for i in _list:
  5.         if type(i) != list:
  6.             outlist.append(i)
  7.         else:
  8.             intern_list = clean_list(set(i))
  9.             outlist.append(intern_list)
  10.     return outlist
  11.  
  12.  
  13. test_list = [["a","a","b","b","c","c"],["a","a","x","x","y","y"]]
  14. #test_list = ["a", ["b","b"]]
  15.  
  16. OUT =  clean_list(test_list)
  17.  
RAW Paste Data