Remove duplicates in a given elements?

Q) Write a program to remove duplicates in a given elements?

Sample Input:-

Enter elements separated by space :
2 3 4 2 2 2 2 2 2 2 1 1 2 3 1 2

Output:-

1 2 3 4

Python code:-


l=[]
print "Enter elements separated by space : "
l=map(int,raw_input().split())
l=list(set(l))
for i in range(len(l)):
      print l[i],



0 comments:

Post a Comment