Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9308657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:40:53+00:00 2026-06-19T00:40:53+00:00

Why doesn’t the following statement return a list without ‘item’ in Python? list(something_convertible_to_list).remove(‘item’) ?

  • 0

Why doesn’t the following statement return a list without 'item' in Python?

list(something_convertible_to_list).remove('item')

?

I would like to use the construction above to avoid explicitly naming a list for the sole purpose of passing it to a function, i.e.:

operate_on_list(list(something_convertible_to_list).remove('item'))

def operate_on_list(my_list):
    # do_something
    print my_list
    return

Is this possible in Python?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:40:55+00:00Added an answer on June 19, 2026 at 12:40 am

    In python, built-in methods which operate in place return None to make it absolutely clear that they mutated an object.

    Of course, you’re free to disregard this convention and write your own wrapper:

    def my_remove(lst,what):
       lst.remove(what)
       return lst
    

    But I wouldn’t recommend it.

    As a side note, if you want to do something like:

    list(something_convertible_to_list).remove('item')
    

    but get the list back, the following might be similar enough to be useful:

    [x for x in something_iterable if x != 'item']
    

    And this does return a list, but where list.remove only takes away 1 'item', this will construct a new list with no 'item' in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why doesn't the following code throw a java.net.BindException: Address already in use: JVM_Bind exception?
It doesn't look like TypeConverter is available to use. What is recommended to replace
Doesn't value have to return toString() to be able to call value.toString()? When do
It doesn't look like it has that attribute, but it'd be really useful to
This doesn't compile and gives the following error: Illegal start of expression . Why?
Why doesn't the following code work? var err = document.getElementById(text-error).value; if (err == Team
Why doesn't Java need to import classes like Integer, String, etc. while it needs
Why doesn't this work? The label is inside the .item parent. I don't want
Why doesn't JSON.stringify() display prop2? var newObj = { prop1: true, prop2: function(){ return
Why doesn't this: def subsets(x): if not x: return [[]] else: return [x +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.