set.pop does not return the first element. As it clearly says in the help that you quoted, it returns an arbitrary element.

And the reason for this is simple: sets are inherently unordered. There is no meaningful "first" or "last" element.1

1. Since sets are stored as hash tables, it makes sense for both performance reasons and simplicity reasons that set.pop will remove the first element in the hash table, which will often be the same as the first element iterated by the set, but that's not guaranteed. And, in fact, exactly when it's true is different in CPython 3.6 - 3.7 than in 3.3 - 3.5.

Answer from abarnert on Stack Overflow
๐ŸŒ
Code.mu
code.mu โ€บ en โ€บ python โ€บ manual โ€บ set โ€บ pop
The pop method - Remove First Element from Set in Python
The pop method removes the first element from a set in Python. We do not specify anything in the method parameter.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_sets_remove.asp
Python - Remove Set Items
Python Examples Python Compiler ... Q&A Python Bootcamp Python Training ... To remove an item in a set, use the remove(), or the discard() method....
Discussions

stack - Why set pop return first element while list pop return last element in python - Stack Overflow
It's a little bit confusing. Is it actually comes from stack pop/push terminology? L.pop([index]) -> item -- remove and return item at index (default last). Raises IndexError if list is empty or More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to retrieve an element from a set without removing it? - Stack Overflow
Although the gap has decreased from the Bad Old Python 2.x days (in which manual iteration was at least four times as fast), it disappoints the PEP 20 zealot in me that the most verbose solution is the best. At least converting a set into a list just to extract the first element of the set ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Removing first element
You are really overcomplicating this problem by using functions and for loops. If its always the first element you're removing then you don't need a for loop at all. It's just a basic slice. some_list = some_list[1:] More on reddit.com
๐ŸŒ r/learnpython
5
1
April 11, 2020
Removing the first element in a file list
mylist.pop(0) or mylist = mylist[1:] will achieve this. More on reddit.com
๐ŸŒ r/learnpython
12
55
November 6, 2021
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ set โ€บ remove
Python Set remove() Function
The remove() method removes the specified element from the set. ... # remove English from the set languages.remove('English') print(languages) # Output: {'Python', 'Java'}
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-remove-items-set
Remove items from Set - Python - GeeksforGeeks
April 19, 2025 - remove() method in Python is used to remove a specific item from a set. If the item is not present it raises a KeyError so it's important to ensure item exists before using it. ... a.remove(3) removes element "3" from the set a and if element ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_remove_set_items.asp
Python Remove Item from Set
Python Examples Python Compiler ... Q&A Python Bootcamp Python Training ... To remove an item in a set, use the remove(), or the discard() method....
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python set remove() โ€“ remove element
Python Set remove() - Remove Element - Spark By {Examples}
May 31, 2024 - The Python set remove() function is used to remove a single element from the Set. The Set in python is a one-dimensional data structure that will not
Find elsewhere
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ sets โ€บ python-sets-exercise-4.php
Python: Remove items from Python set - w3resource
Write a Python program to remove item(s) from a given set. ... # Create a set 'num_set' with the elements 0, 1, 3, 4, and 5 using a list: num_set = set([0, 1, 3, 4, 5]) # Print a message to indicate the original set: print("Original set:") # Print the contents of the 'num_set': print(num_set) # Remove and return the first element from 'num_set' using the 'pop' method: num_set.pop() # Print a message to indicate the set after removing the first element: print("\nAfter removing the first element from the said set:") # Print the updated 'num_set' without the first element: print(num_set)
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-removing-first-element-of-list
Remove first element from list in Python - GeeksforGeeks
Explanation: a.pop(0) removes and returns the first element of the list, shifting the remaining elements left. The list is updated in place and the removed element is no longer part of the list.
Published ย  July 11, 2025
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ standard-library โ€บ set โ€บ remove
Python Set remove() - Remove Element | Vultr Docs
December 10, 2024 - ... primary_set = {1, 2, 3, 4, ... in reference_set, useful for maintaining exclusive data sets without overlap. The remove() method in Python sets is a fundamental tool for dynamically managing the elements within ...
๐ŸŒ
Quora
quora.com โ€บ How-do-I-remove-an-element-from-set-Python
How to remove an element from set Python - Quora
Answer (1 of 2): Go into your Python interpreter and type [code ]help(set)[/code]. Or go to the Python documentation for the set type. Look at the methods available. Does one of them sound like it could remove an element? Or more than one? In that case, look at the descriptions and see which on...
๐ŸŒ
PythonForBeginners.com
pythonforbeginners.com โ€บ home โ€บ remove elements from a set in python
Remove Elements From a Set in Python - PythonForBeginners.com
May 11, 2022 - The input set is: set() ...Projects/pythonProject/string1.py", line 3, in <module> element = mySet.pop() KeyError: 'pop from an empty set' The pop() method removes a random element from the set....
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_set_remove.asp
Python Set remove() Method
Python Examples Python Compiler ... Plan Python Interview Q&A Python Bootcamp Python Training ... The remove() method removes the specified element from the set....
๐ŸŒ
Linux Hint
linuxhint.com โ€บ remove-element-from-set-python
Linux Hint โ€“ Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
HackerRank
hackerrank.com โ€บ challenges โ€บ py-set-discard-remove-pop โ€บ problem
Set .discard(), .remove() & .pop() | HackerRank
>>> s = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> s.discard(5) >>> print s set([1, 2, 3, 4, 6, 7, 8, 9]) >>> print s.discard(4) None >>> print s set([1, 2, 3, 6, 7, 8, 9]) >>> s.discard(0) >>> print s set([1, 2, 3, 6, 7, 8, 9]) ... This operation removes and return an arbitrary element from the set.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ removing first element
r/learnpython on Reddit: Removing first element
April 11, 2020 -

I find myself not using built-in syntax. I want to write from scratch. My reasoning is, this will strengthen my fundamentals. This is also draining, since I'm very new to programming, not just Python. I don't know if this is worth it - it could be causing more stress.

---------------

Here is a problem, with a very simple solution using the remove method. And I am complicating this.

I need your guidance:

a. Should I stop wrestling with writing code from scratch, and just get on with simple solutions. In problem below, not only am I trying with for loop, I also want to try with del. Am I being an idiot wasting time.

b. A solution to the problem below without using the remove method.

c. A site that explains algorithm behind methods such as remove. I've tried searching. Sample search terms I used: "python programs without using built-in methods" "remove method from scratch Python", "remove method algorithm"

-------------

Task: Create a function, remove_first, that takes a list as first argument, and an element in the list as second object. Removes the occurrence with the lowest index from the first argument. Pulls all following elements one position to the left. Modifies the list in place.

Solution given:

def remove_first(some_list, element):
    some_list.remove(element)

Code I am experimenting with:

def remove_first(list1,obj):

for i in range(len(list1)): if list1[i]==obj: print(i) print(list1[:i]+list1[i+1:])

remove_first(['apple','bat','crow','daisy','potato','apple'],'apple')

Output:

Output I get is wrong. I am trying to figure out how to fix this code.

0
['bat', 'crow', 'daisy', 'potato', 'apple']
5
['apple', 'bat', 'crow', 'daisy', 'potato']

Thank you.

๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ python โ€บ sets
Sets in Python: Create, Add, Remove With Examples
October 1, 2025 - Learn Python Sets with examples in this tutorial. Understand how to use sets in Python, including practical examples and tips for efficient data handling.