Python List pop() MethodPython's pop() element removes the element from the list that is present at the given index. The popped element is returned. On this page, the syntax and signature are explained. SignatureParametersX: being popped element. It's not required. ReturnThe popped element is returned. To comprehend the operation of the pop() method, let's look at some samples. Example 1First, look at a straightforward example of popping an element from a list. See the example below for how an element present at index two gets popped. Output: 1 2 3 After poping: 1 2 Example 2The index is optional; if left blank, the element will pop up at the end of the list. See the illustration below. Output: 1 2 3 After poping: 1 2 Example 3The entry from the right of the list will be displayed if the index value is negative. see the illustration below Output: 1 2 3 After poping: 1 3
Next TopicPython Lists
|