It is a method in list that pops out an item from a specified position in the list. It returns the popped item and modifies the original list.
Syntax:
list.pop(position)
*Position is optional, by default it’s -1 and it pops out the last item.
Don’t know what is insert method in python? Read: insert() method in Python List
Example 1:
s = [2, 8, 7, 9, 33, 45, 52]
x = s.pop()
print(x)
print(s)
Output:
52
[2, 8, 7, 9, 33, 45]
Explanation:
Here the method pops out the last element “52” from the end of the list. The original list is modified as the element is popped out of the list.
Example 2:
s = [2, 8, 7, 9, 33, 45, 52]
x = s.pop(1)
print(x)
Output:
8
Explanation:
Here the method popped out the element at index 1 i.e. “8” from the original list
Example 3:
s = ["Name", "codewindow", "Country", "India"]
s.pop(2)
print(s)
Output:
[‘Name’, ‘codewindow’, ‘India’]
Explanation:
Here the element “Country” which was at index 2 was popped out from the original list.
You Missed
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- React JS – codewindow.in
- React JS – codewindow.in
- Constant Pointer in C
- JavaScript – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Big Data – codewindow.in
- Big Data – codewindow.in
- Big Data – codewindow.in
- Big Data – codewindow.in
- Big Data – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Python – codewindow.in
- Big Data – codewindow.in
- Big Data – codewindow.in
- Ajax – codewindow.in
- Ajax – codewindow.in
- Ajax – codewindow.in
- Ajax – codewindow.in
Also Checkout
- Adobe
- Ajax
- Algorithm
- Amagi
- Amazon Interview Questions
- Aptitude
- big data
- Books
- Bridge2i
- C programming
- Campgemini Interview Questions
- Capgemini Coding Questions
- Capgemini Pseudocode
- Celebal Tech
- code nation
- CodeVita
- Coding Questions
- Cognizant Placement
- commvault Systems
- CTS
- Data Science
- Data Structure and Algorithm
- De Show Interview Questions
- deloitte
- Deutsche Bank Interview questions
- Epam Full Question Paper
- Exxon Mobil interview questions
- filpkart
- Fractal Analytics Interview Questions
- Genpact
- Grab
- GreyB Interview Questions
- Guidance for Accenture
- Gupshup
- HCL Interview Questions
- Hexaware
- HFCL
- HR Questions
- HTML5
- IBM Interview questions
- IBM Questions
- Incture Interview Questions
- Infineon Technologies Interview Questions
- Infosys
- Infosys Interview Questions
- Internship
- Interview Experience
- Interview Questions
- ITC Infotech
- itron
- JavaScript
- JECA
- Job Info
- Kantar Interview Questions
- Larsen & Turbo
- Latenview AnalyticsInterview questions
- Lexmark International Interview Questions
- Machine Learning
- Media.net
- Mindtree Interview Questions
- Miscellaneous
- Morgan Stanly Interview Questions
- nagarro
- navi
- NodeJS
- NPCI
- NTT Data Interview Questions
- NVDIA
- NVDIA interview questions
- Optum
- PayU
- Persistent INterview Questions
- Programming in C
- Programming in C++
- Programming in JAVA
- Programming in Python
- Project
- pseudocode
- PWC Interview Questions
- Python
- Quiz
- Razorpay
- ReactJS
- Recruiting Companies
- Revature
- salesforce
- Samsung
- Schlumberger
- Seimens
- Slice
- Smart Cube
- Study Material
- Tally Solutions
- tata cliq
- TCS
- TCS NQT
- TCS NQT Coding Questions
- Tech Mahindra Coding Questions
- Tech Mahindra Questions
- Teg Analytics
- Tejas Network Interview Questions
- Texas Instrument Interview Questions
- Tiger Analytics
- Uncategorized
- UnDosTres
- Unstop
- Verbal Ability
- Web Development
- Wipro Coding Questions
- Wipro interview Questions
- Wipro NLTH
- WIpro NLTH Coding Solve
- Zenser
- Zoho Interview Questions