Code:-
n=int(input("Enter number of elements"))
mylist=[]
for i in range(n):
ele=int(input())
mylist.append(ele)
print("list before deletion of repeated element\n",mylist)
new_list=[]
for i in mylist:
if i not in new_list:
new_list.append(i)
print("List after deletion of duplicates\n",new_list)
Output:-
Enter number of elements10
1
2
3
4
5
4
3
2
1
3
list before deletion of repeated element
[1, 2, 3, 4, 5, 4, 3, 2, 1, 3]
List after deletion of duplicates
[1, 2, 3, 4, 5]
0 Comments