Python List pop() MethodPython pop() element removes an element present at specified index from the list. It returns the popped element. The syntax and signature is described below. SignatureParametersx : Element to be popped. It is optional. ReturnIt returns popped element. Let's see some examples of pop() method to understand it's functionality. Python List pop() Method Example 1Let's first see a simple example of popping element from the list. Element present at the index 2 is popped, see the example below. Output: 1 2 3 After poping: 1 2 Python List pop() Method Example 2The index is optional, if we don't specify the index, it pops element presents at the last index of the list. See the example below. Output: 1 2 3 After poping: 1 2 Python List pop() Method Example 3If the index is a negative value, it will pop element from the right of the list. See the example below. Output: 1 2 3 After poping: 1 3
Next TopicPython Lists
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week