Advertisement
DrAungWinHtut

duplicate.py

Aug 14th, 2022
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. li1 = ['a', 'a', 'b', 'b', 'b', 'a', 'b', 'aa', 'a', 'b', 'c']
  2. temp = []
  3. final = []
  4. i = 0
  5. flag = True
  6.  
  7. for i in range(len(li1)):
  8.     for j in range(i+1, len(li1)):
  9.         flag = True
  10.         if temp != []:
  11.             for k in temp:
  12.                 print(i)
  13.                 print(j)
  14.                 print(k)
  15.                 print()
  16.                 if(k == j):
  17.                     flag = False
  18.  
  19.         if((flag == True) and (li1[i] == li1[j])):
  20.             temp.append(j)
  21.  
  22. print(temp)
  23.  
  24. temp.sort()
  25. print(temp)
  26.  
  27.  
  28. for i in range(len(li1)):
  29.     flagOK = True
  30.     for l in temp:
  31.         if i == l:
  32.             flagOK = False
  33.  
  34.     if(flagOK == True):
  35.         final.append(li1[i])
  36.  
  37.  
  38. print("final = ")
  39. print(final)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement