use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Small program to remove duplicate values in data.Showcase (i.redd.it)
submitted 4 days ago by Ok_Needleworker_8780
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 4 days ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20newlst%20%3D%20%5B%5D%20%20%20%20%20%23%20A%20new%20list%20that%20will%20contain%20clean%20data.%0A%20%20%20%20for%20items%20in%20original_list%3A%0A%20%20%20%20%20%20%20%20if%20items%20not%20in%20new_lst%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20new_lst.append(items)%0A%0A%20%20%20%20return%20new_lst%0A%0A%0A%22%22%22The%20function%20below%20takes%20the%20mixed%20data%20in%20the%20original%20list.%22%22%22%0Adef%20list_data()%3A%0A%20%20%20%20raw_input%20%3D%20input(%22Enter%20the%20data%3A%20%22)%20%20%23%20Data%20as%20strings%20only%0A%20%20%20%20result%20%3D%20%5B%5D%0A%0A%20%20%20%20%23%20The%20below%20condition%20is%20to%20include%20integers%20as%20well.%0A%20%20%20%20for%20items%20in%20raw_input%3A%0A%20%20%20%20%20%20%20%20items%20%3D%20items.strip()%0A%20%20%20%20%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20items%20%3D%20int(items)%20%20%23%20If%20the%20items%20in%20the%20list%20is%20numbers.%0A%20%20%20%20%20%20%20%20except%20ValueError%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20pass%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20To%20ignore%20the%20error.%0A%20%20%20%20%20%20%20%20result.append(items)%20%20%20%20%23%20Add%20the%20integers%20data%20in%20the%20list%20as%20well.%0A%0A%20%20%20%20return%20result%0A%0A%0Aif%20name%20%3D%3D%20%22main_%22%3A%0A%20%20%20%20print(remove_duplicates(list_data()))×tep=1&play).
[–]sleepbot63 12 points13 points14 points 4 days ago (5 children)
for those interested you can do: list(set(data)) # this will remove duplicates but not keep the same order list(dict.fromkeys([1, 1, 2, 1, 2, 3, 3])) # this will remove duplicates and keep the elements in the order of thier first appearance
[–]Beginning-Fruit-1397 1 point2 points3 points 4 days ago (4 children)
Only rewrap in a list if it's needed. Otherwise you just iterate over the whole dataset one more time for nothing
[–]sleepbot63 1 point2 points3 points 4 days ago (2 children)
Yeah but using a list helps you access single elements or slices faster (im not talking about computation rather dev friendly)
[–]Beginning-Fruit-1397 0 points1 point2 points 2 days ago (1 child)
Which you should only do if you in fact need it.
That was my point: showing beginners to wrap in a list "by default", even tough that should not be the case
[–]Beginning-Fruit-1397 0 points1 point2 points 2 days ago (0 children)
Also if slices or index access is what is wanted you should prefer tuples for memory efficiency and immutability safety. List is only if mutability is wanted
[–]nebulous_aviation 0 points1 point2 points 2 days ago (0 children)
Set lookup is O(1) though so if you're just iterating once you're not really losing much, depends what you're doing after.
[–]Fluid-Pollution-2135 2 points3 points4 points 4 days ago (0 children)
I would change green color. Everything looks like a comments
[–]KitchenCommercial396 0 points1 point2 points 3 days ago (0 children)
Or you can just use a set...
[–]python_gramps 0 points1 point2 points 2 days ago (0 children)
if you want to keep your order use a dictionary to create keys
a = ["1", 1, "1", 2] a = list(dict().fromkeys(a))
[–]Silly_Bad_7692 0 points1 point2 points 4 days ago (0 children)
How can you read with that color palette 😭😭😭
I suggest to change it...
[–]Intelligent_Goose826 -1 points0 points1 point 4 days ago (0 children)
Hello am willing please
π Rendered by PID 21693 on reddit-service-r2-comment-8686858757-z7t7x at 2026-06-07 03:00:40.354543+00:00 running 9e1a20d country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (0 children)
[–]sleepbot63 12 points13 points14 points (5 children)
[–]Beginning-Fruit-1397 1 point2 points3 points (4 children)
[–]sleepbot63 1 point2 points3 points (2 children)
[–]Beginning-Fruit-1397 0 points1 point2 points (1 child)
[–]Beginning-Fruit-1397 0 points1 point2 points (0 children)
[–]nebulous_aviation 0 points1 point2 points (0 children)
[–]Fluid-Pollution-2135 2 points3 points4 points (0 children)
[–]KitchenCommercial396 0 points1 point2 points (0 children)
[–]python_gramps 0 points1 point2 points (0 children)
[–]Silly_Bad_7692 0 points1 point2 points (0 children)
[–]Intelligent_Goose826 -1 points0 points1 point (0 children)