Advertisement
kajs54

EX5 TD BInomes

Oct 27th, 2022
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 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 nbr(x,l):
  15.     nbr=0
  16.     for i in range(n):
  17.         if l[i]==x:
  18.             nbr+=1
  19.     return nbr
  20. def doub(l):
  21.     for i in range(len(l)-1):
  22.         for  j in range(i+1,len(l)):
  23.             if (l[i] in l[j:]) and not(l[i] in double):
  24.                 double.append(l[i])
  25.     return double
  26.  
  27. print("les elements double sont:",doub(l))
  28. def uni(l):
  29.     for i in range(len(l)):
  30.         if not(l[i] in unique) and not(l[i] in double):
  31.             unique.append(l[i])
  32.     return unique
  33. print("les elements uniques sont:",uni(l))
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement