Python Program to Remove Duplicate Elements from a List

Python Program to Remove Duplicate Elements from a List

Example Program

3 года назад

89,546 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Kevin Vélez
Kevin Vélez - 05.10.2023 17:36

data = [10,20,20,30,40,50,50]

def remove_duplicate(data, i):
if i >= len(data):
return data
if isinstance(data[i], int):
if data[i] == data[i+1]:
data.pop(i)
return remove_duplicate(data, i+1)
print(remove_duplicate(data, 0))

Ответить
shubham kumar
shubham kumar - 15.06.2023 18:06

This program is wrong

Ответить
Escape Felicity
Escape Felicity - 26.05.2023 12:13

It might be a REAL GOOD IDEA to post the code

Ответить
Veeba Sauce
Veeba Sauce - 01.05.2023 20:57

Your explanation is not to the point.
Can't understand what are saying.

Ответить
Siddig Amer
Siddig Amer - 14.01.2023 14:59

Thank you very much>>>...

Ответить
Carl Fernandez
Carl Fernandez - 12.12.2022 15:35

Can't you sort it, loop through the array comparing it to the last element and if so delete that that element/append it if not, to a noduplist. Then it sorts in nlog(n) time and runs in n time. This will run in worst case (n/2)^2. which is worse after 8 elements.

Ответить
Telugu ghost lovers Ka adda
Telugu ghost lovers Ka adda - 20.11.2022 07:49

Please tell me how to remove alternative eliminats in a list

Ответить
Attachment Studios
Attachment Studios - 16.10.2022 11:06

Use this rather maybe if you wanna reduce lines of code:

# Function
remove_duplicates = lambda input_list:list(dict({key:0 for key in input_list}))

# Example/Usage
my_list = [...]
my_list = remove_duplicates(my_list)

Ответить
Vashista Thakuri
Vashista Thakuri - 06.09.2022 10:23

You can just convert it to a set and convert it back to a list.

Ответить
Gladwin Newton
Gladwin Newton - 10.08.2022 12:22

Thank you

Ответить
Karisa Michael
Karisa Michael - 29.07.2022 12:35

Nice video but...?

How do you delete the '+' in the list below?
My_list=[+1222..., +1838..., 1737...]

Ответить
Hayk Mano
Hayk Mano - 10.07.2022 13:02

but how to remove duplicate with that number for example numbers=[2,2,4,4,6,8,8,9] it will be unique =[6,9] . how to solve that problem?

Ответить
Pat M.
Pat M. - 20.04.2022 04:40

nice

Ответить
Mohammad Aslam
Mohammad Aslam - 14.03.2022 05:29

Sir pls.. say sir
Noduplist is a empty list
But how we check if the element present in noduplist or not...

Ответить
Anil Kumar
Anil Kumar - 13.03.2022 18:59

Sir what is the output for 1-2,2-3,3-4,4-5

Ответить
Alfonso Ramirez Elorriaga
Alfonso Ramirez Elorriaga - 03.03.2022 08:40

It would be great if you could show how to do it withouth the "not in" method. That is what I am trying to do. I am trying to loop through "unique" and if "i" is not equal to "j" then I append i to unique. However, I am doing something wrong sintaxis wise.

Ответить
Sinen GAZZAH
Sinen GAZZAH - 11.12.2021 22:26

i swear i love u bro

Ответить
Rohit Raj
Rohit Raj - 30.10.2021 15:14

It's not working in my system. Error says function object not iterable

Ответить
Ammad Ammad
Ammad Ammad - 26.09.2021 00:46

Can we count the duplicate numbers In a list without using count built-in function?
I want an output like...
(Number, repeated x times)

Ответить
Sanjay Changhate
Sanjay Changhate - 17.09.2021 15:47

Thanks sire u helped me a lot😘😘😘

Ответить
riad al hasan abir
riad al hasan abir - 05.09.2021 07:05

thank you so much it solved my assignment

Ответить
Rajeswaran R
Rajeswaran R - 28.08.2021 09:00

Awsm❤️

Ответить
Itz Hyp3r
Itz Hyp3r - 16.08.2021 03:14

YOU SAVED MY LIFE!!!!!!!

Ответить
SUMIT
SUMIT - 20.07.2021 09:27

For elements in duplist likhna jaruri hai kya ?

Ответить
Mayank
Mayank - 12.07.2021 06:12

You made your code so complex you could just convert the list to sets and all duplicates would be gone

Ответить
06_Shubham Birhade
06_Shubham Birhade - 10.06.2021 20:43

This program question is asked in every interview

Ответить
Dosko Cedar
Dosko Cedar - 22.05.2021 13:49

when I heard an Indian accent I knew, I'd learn something today.

Ответить
HotRoad COL
HotRoad COL - 12.05.2021 15:24

Thanks

Ответить
HotRoad COL
HotRoad COL - 12.05.2021 15:24

👍👍👍

Ответить
MY MANTRA
MY MANTRA - 28.04.2021 18:13

We can convert the list into set to remove duplicates

Ответить
Areeb Tahir
Areeb Tahir - 16.04.2021 22:23

Sir ye har value ke liye kam nhi krega.
While loop se krye ek baar

Ответить
penny wise
penny wise - 12.04.2021 18:21

Bro u put that duplicate list into set datatype and you again convert the set to the list data type and print the list like this
List1=[ 1,5,6,4,2,3,3,3]
Set1=set(list1)
List1= list(set1)
Print(list1)

Ответить
Thoth IV
Thoth IV - 04.04.2021 23:54

Thanks sire u helped me solve my assignment 🇳🇬💗💗

Ответить
Fred Soda
Fred Soda - 29.03.2021 00:44

Thank you. I appreciate your Support for the Community.

Ответить
Lost Frequency
Lost Frequency - 27.03.2021 23:49

Is this even efficient?

Ответить
Gianluca Caredda
Gianluca Caredda - 11.03.2021 02:19

I am trying to print also the noduplist by the console tells me that it is not defined. What should I do ??

Ответить
Lindsay
Lindsay - 10.03.2021 07:18

thank you, dawg. appreciate ya

Ответить
Susanta Vlogs
Susanta Vlogs - 16.02.2021 11:16

for loop would be performance killer if we have a big list...

Ответить
Abhishek kumar
Abhishek kumar - 21.01.2021 21:11

This is really helpful

Ответить
Flipaclip- Animators
Flipaclip- Animators - 16.01.2021 17:14

Nice work

Ответить