heapify returns NoneType

0 votes

I have the following code:

b = heapify([5,4,9,1])

and when I check for the following

type(b)

It shows it's NoneType instead of list type. How do I fix this issue?

Jul 26, 2019 in Python by ana1504.k
• 7,890 points
75 views

1 answer to this question.

0 votes

The heapify() method transforms the list in-place. This means that it alters the list, but does not return the modified list. As agf mentions below, heapify() returns None to protect you from this mistake. Therefore, if you do

lst = [5,4,9,1]
heapify(lst)
type(lst)

you will see that lst is now heapified.

answered Jul 26, 2019 by SDeb
• 13,230 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
0 answers

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Hi guys i have below code . ...READ MORE

Oct 30, 2019 in Python by sumanth
• 190 points
1,627 views
0 votes
1 answer
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 772 views
0 votes
0 answers
0 votes
1 answer

Web3j Transfer.sendFunds() returns Error “insufficient funds for gas * price + value”

DISCLAIMER. This may not necessarily be an answer to your ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,760 points
563 views
0 votes
1 answer

Web3j v3.3.1 : Error while generating compiled solidity smart contracts which returns array of struct

Solidity does not support returning structs in ...READ MORE

answered Jun 19, 2018 in Blockchain by aryya
• 7,350 points
318 views