Computer Science
Write a program to move all duplicate values in a list to the end of the list.
Python
Python List Manipulation
41 Likes
Answer
l = eval(input("Enter the list: "))
dedup = []
dup = []
for i in l:
if i in dedup:
dup.append(i)
else:
dedup.append(i)
l = dedup + dup
print("Modified List:")
print(l)
Output
Enter the list: [20, 15, 18, 15, 7, 18, 12, 13, 7]
Modified List:
[20, 15, 18, 7, 12, 13, 15, 18, 7]
Answered By
18 Likes
Related Questions
Write programs as per following specifications:
'''L is a list of numbers. Print a new list where each element is the corresponding element of list L summed with number num.'''
Write a program to read two lists num and denum which contain the numerators and denominators of same fractions at the respective indexes. Then display the smallest fraction along with its index.
Write a program to display the maximum and minimum values from the specified range of indexes of list.
Write a program to compare two equal sized lists and print the first index where they differ.