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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:08:50+00:00 2026-06-17T03:08:50+00:00

i have just confronted this situation which i am not able to understand: In

  • 0

i have just confronted this situation which i am not able to understand:

In [3]: nk1=range(10)

In [4]: nk2=range(11,15)

In [5]: nk1.extend(nk2)

In [6]: nk1
Out[6]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14]

In [7]: dir(range(10))==dir(list)==dir(range(11,15))==dir(nk1)==dir(nk2)
Out[7]: True

In [8]: print range(10).extend(range(11,15))
None

as you can see above that i can easily extend nk1, but why not the last statement which is returning None??
why it is returning None in In[8] input (while from In[7] we can see that all are same)???
so do i always have to make instance of range to extend it???

from python docs; i found this; but i am not getting how does above case happened.

  • 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-17T03:08:51+00:00Added an answer on June 17, 2026 at 3:08 am

    When you extend a list the list is modified in-place. A new list is not returned.

    In-place modifications indicate that the object whose method you’re calling is going to make changes to itself during that method execution. In most cases (to avoid the confusion you’re currently encountering) these types of operations do not return the object that performed the operation (though there are exceptions). Consider the following:

    list1 = range(10)
    list2 = range(10) + range(11,15) # no in place modification here.
    nolist1 = list1.extend(range(11,15)) # list1 is now (0 ... 14)
    nolist2 = range(10).extend(range(11,15)) # Nothing actually happens here.
    

    In the final example, the range function returns a list which is never assigned to anything. That list is then extended, the result of which is a return value of None. This is printed.

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

Sidebar

Related Questions

I have just found out this syntax for a scala Map (used here in
I have just spent half an hour figuring this thing out, I have managed
I have just created this table: create table dbo.OrderTypes ( ID smallint primary key
We have just migrated from solr3.5 to solr3.6, for all this time we have
I have just coded an email design, tested it in Litmus & found out
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have just started out with EF for Oracle in targeting .Net 4.0. Have added
Have just come across a problem where I believe this is the solution. At
I have just replaced CKEditor (which came with a wealth of mysterious problems relating
I have just formatted an external hard disk using this command: $ sudo mkfs

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.