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
- IBM Off-Campusing Drive | Application Developer: Java Full Stack | codewindow.in
- IBM Off-Campusing Drive | Brand Technical Specialist | codewindow.in
- Mindtree Off-Campusing Drive | Technical Architect – Adobe Analytics | codewindow.in
- Cognizant Off-Campusing Drive | GenC – Java Developer | codewindow.in
- Capgemini Off-Campusing Drive | Data Analyst | codewindow.in
- Accenture Off-Campusing Drive | Bilingual Hiring- Tech-Associate Software Engineering | codewindow.in
- Infosys Off-Campusing Drive | Associate Finance | codewindow.in
- Mindtree Off-Campusing Drive | GCP BigQuery – Technical Lead | codewindow.in
- Wipro Off-Campusing Drive | Project Engineer | codewindow.in
- Top 100 Java Interview Questions & Answers | Set 2 – codewindow.in
- TCS NQT Solved Paper 12th Sept 2021 – Part 6 – codewindow.in
- Morgan Stanley Off-Campusing Drive | Analyst | codewindow.in
- footer 2022
- Elementor #31191
- TCS NQT Solved Paper 12th Sept 2021 – Part 5 – codewindow.in
- Top 100 Java Interview Questions & Answers | Set 1 – codewindow.in
- Xl Dynamics Solutions Recruitment Drive – Multiple Roles – Codewindow.in
- TCS NQT Solved Paper 12th Sept 2021 – Part 4 – codewindow.in
- KPIT Technologies hiring 2022 Batch – Trainee Engineer – Codewindow.in
- Protected: Off Campus Recruitment Drive #31034
- TCS NQT Solved Paper 12th Sept 2021 – Part 3 – codewindow.in
- TCS NQT Solved Paper 12th Sept 2021 – Part 2 – codewindow.in
- TCS NQT Solved Paper 12th Sept 2021 – Part 1 – codewindow.in
- CDK Global Recruitment Drive – Graduate Trainee – Codewindow.in
- Microsoft Off Campus Recruitment Drive 2023 – SWE – Codewindow.in
- Aptitude Made Easy | Average – codewindow.in
- Accenture Non-Tech Recruitment Drive – B.com/BBA – Codewindow.com
- Aptitude Made Easy | Work and Time – codewindow.in
- Google Off Campus Hiring Drive – Software Engineer – Codewindow.in
- Aptitude Made Easy | Problems on Numbers – codewindow.in
- Symmetric Difference Code
- ZOHO Off-Campusing Drive | Software Developer | codewindow.in
Also Checkout
- Algorithm
- Aptitude
- Capgemini Coding Questions
- Capgemini Pseudocode
- CodeVita
- Coding Questions
- Cognizant Placement
- Data Structure and Algorithm
- Epam Full Question Paper
- Guidance for Accenture
- HR Questions
- IBM Questions
- Infosys
- Internship
- Interview Experience
- Interview Questions
- JECA
- Job Info
- Machine Learning
- Miscellaneous
- NPCI
- Programming in C
- Programming in C++
- Programming in JAVA
- Programming in Python
- Quiz
- Recruiting Companies
- Revature
- Study Material
- TCS NQT
- Tech Mahindra Coding Questions
- Tech Mahindra Questions
- Uncategorized
- Verbal Ability
- Web Development
- Wipro Coding Questions
- Wipro NLTH
- WIpro NLTH Coding Solve