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 7971027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:32:43+00:00 2026-06-04T07:32:43+00:00

I am a newbie to python,everywhere I read about list methods I see one

  • 0

I am a newbie to python,everywhere I read about list methods I see one thing

The slice method returns a “new” list

What is here meant by “new” list,and why is it faster then changing the original list?

Does it really matter if python manipulates the original list,I mean I cant use it anyway.

  • 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-04T07:32:45+00:00Added an answer on June 4, 2026 at 7:32 am

    I hope that this helps explain what it means by making a new list:

    >>> lista = [1, 2, 3, 4]         
    >>> listb = lista
    >>> print lista
    [1, 2, 3, 4]
    >>> print listb
    [1, 2, 3, 4]
    >>> lista[0] = 3
    >>> print listb
    [3, 2, 3, 4]
    >>> listc = lista[:]
    >>> print listc
    [3, 2, 3, 4]
    >>> lista[0] = 1
    >>> print listc
    [3, 2, 3, 4]
    

    When doing listb = lista you are not making a new list, you are making an additional reference to the same list. This is shown by changing the first element in lista with lista[0] = 3, this also changes the first element in listb. However, when slicing lista into listc with listc = lista[:] you are copying over the values. When changing the first element of lista back to 1 with lista[0] = 1, the first element of listc is still 3.

    For speed I would expect slicing to be slower but this should not be a consideration for which one to use. As I’ve shown they both have a very different implication and it depends on what you are going to do with the list, rather than on speed (this is in general. There are occasion where the speed might be important).

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

Sidebar

Related Questions

Here's a bit of a newbie Python question about instance variables. Consider the following
I'm a newbie in Python and I'm studying list comprehension. What I'm trying to
Python newbie here and wanted to know if there was a way to combine
python newbie here. I'm writing the code to control an experiment that has multiple
I'm a Python newbie, so I'm sure this is easy. Here's the code in
OK - Python newbie here - I assume I am doing something really stupid,
Newbie to python here, I am trying to use an integer as an argument
Python newbie here. I'm writing an SMTP server using Twisted and twisted.mail.smtp. I'd like
Python newbie here, running 2.7. I am trying to create a program that uses
I am a newbie to python. I have to create an ordered list in

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.