How to Remove Duplicates From a List Using Python.

by ludwigvincent64 in Circuits > Software

117 Views, 0 Favorites, 0 Comments

How to Remove Duplicates From a List Using Python.

Screen Shot 2021-05-19 at 9.34.34 PM.png

Hello! In this instructable I will be showing you how to remove duplicates from a list and assign them to another list.

Supplies

A computer.

A Python code editor.

Making the Lists.

Screen Shot 2021-05-19 at 9.28.44 PM.png

Make a list of numbers, make sure to add some duplicates so we can test it out when we are done. Then, make another list. This is going to be our result.

Making a for Loop.

Screen Shot 2021-05-19 at 9.32.06 PM.png

Then make a for loop iterating over our list of numbers. And if the numbers are not in our results list, we append them to it.

Printing the Results.

Screen Shot 2021-05-19 at 9.34.03 PM.png

Now, we can print the results to the console. And voila! We removed the duplicates from a list.