Advertisement
kajs54

EX6 TD Binomes

Oct 17th, 2022
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. unique=[]
  2. l=[]
  3. double=[]
  4. n=int(input("donner le longueur de la liste:"))
  5. x=0
  6. for i in range(n):
  7.     x=int(input("donner un entier:"))
  8.     l.append(x)
  9. def uni(l):
  10.     for i in range(len(l)):
  11.         if not(l[i] in unique):
  12.             unique.append(l[i])
  13.     return unique
  14. def doub(l):
  15.     for i in range(len(l)-1):
  16.         for  j in range(i+1,len(l)):
  17.             if (l[i] in l[j:]) and not(l[i] in double):
  18.                 double.append(l[i])
  19.     return double
  20.  
  21. print("les elements double sont:",doub(l))
  22. def uni(l):
  23.     for i in range(len(l)):
  24.         if not(l[i] in unique) and not(l[i] in double):
  25.             unique.append(l[i])
  26.     return unique
  27. print("les elements uniques sont:",uni(l))
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement