Skip to main content

How To Remove Last Element In A List?

Last Updated: Asked By 1 Answers Answered

Here is a List:

    list = ["Red", "Blue", "Green","Silver", "Yellow", "Gray"]

I want to remove last element from List. How to do this using Python?

Share:

1 Answer

S
Sadique Community Contributor Answered on

Using the pop() method in Python, You can delete the last element in a list

    list = ["Red", "Blue", "Green","Silver", "Yellow", "Gray"]
    list.pop()
    print(list)

Output:

    ['Red', 'Blue', 'Green', 'Silver', 'Yellow']

Your Answer

Other Resources

Quiz Image
Quiz

Test your knowledge with interactive quizzes.

Interview Questions Image
Interview Questions

Prepare for interviews with curated question sets.

Q&A Image
Q&A

Ask your coding-related doubts and get answers.

Certification Image
Certification

Earn certifications to enhance your resume.

internships Image
Internships

Hands-on projects to improve your skills.

Quiz Image
Quiz

Test your knowledge with interactive quizzes.

Interview Questions Image
Interview Questions

Prepare for interviews with curated question sets.

blog Image
Blogs

Add your technical blogs and read technical topics.

Certification Image
Certifications

Earn certifications to enhance your resume.