Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unique=[]
- l=[]
- double=[]
- n=int(input("donner le longueur de la liste:"))
- x=0
- for i in range(n):
- x=int(input("donner un entier:"))
- l.append(x)
- def uni(l):
- for i in range(len(l)):
- if not(l[i] in unique):
- unique.append(l[i])
- return unique
- def doub(l):
- for i in range(len(l)-1):
- for j in range(i+1,len(l)):
- if (l[i] in l[j:]) and not(l[i] in double):
- double.append(l[i])
- return double
- print("les elements double sont:",doub(l))
- def uni(l):
- for i in range(len(l)):
- if not(l[i] in unique) and not(l[i] in double):
- unique.append(l[i])
- return unique
- print("les elements uniques sont:",uni(l))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement