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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:06:12+00:00 2026-06-12T13:06:12+00:00

I have a list named mylist. If I enter print mylist in my program

  • 0

I have a list named mylist. If I enter print mylist in my program and I am able to print my list and see the items. I then transfer the list items into a heap queue:

 myheap=heapq.heapify(mylist)
 print myheap

It prints None. What is wrong?

  • 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-12T13:06:13+00:00Added an answer on June 12, 2026 at 1:06 pm

    You failed to read the docs:

    heapify(x)

    Transform list x into a heap, in-place, in linear time.

    The heapify() method convers the list in-place, it doesn’t return a new list. You should print mylist:

    >>> a=[43,12,4,1,5,3,5,3,5,2,64,352,36]
    >>> import heapq
    >>> heapq.heapify(a)
    >>> a
    [1, 2, 3, 3, 5, 4, 5, 12, 5, 43, 64, 352, 36]
    

    As pointed out in a comment, this is a bit odd for a Pythonn API. I don’t know for certain, but I guess it has been done for efficiency’s sake. Still, of course the heapify() function could just return the input reference, to make it less surprising.

    If the API had been a constructor, which returns a newly constructed object like you expected, it would very probably have been named differently, perhaps:

    myheap = heapq.HeapQ(a)  # This is not valid code.
    

    The casing and naming of the function are both strong hints this is not a regular constructor.

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

Sidebar

Related Questions

Let's say I have a list named mylist = [] This list contains sentences
I have quite large List named items (>= 1,000,000 items) and some condition denoted
I have something like @XmlElementWrapper(name=Mylist) List<Items> myItems = new ArrayList<Items>() and that comes out
I have an array list named newSymptomList which contains a list of Symptom id's
I have a named list that looks like this: > head(pathways) $<NA> NULL $`2`
I have a list of methods that I want to call named Method1, Method2,
So let's assume I have a class named ABC that will have a list
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created
I have an entity named Commercial. I have an Category entity where the list
I have a Linux box and I want to be able to telnet into

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.