My function returns None, Python 3

Question:

I am not too sure why this returns None, it worked perfectly before I tried putting it into a function. It is supposed to return a list of words that are between 6 and 9 characters long.

def level_list(minn, maxx):
    for words in word_list:
        if len(words) >= minn and len(words) <= maxx:
            return level_words.append(words)

print(level_list(6, 9))
Asked By: dhcrain

||

Answers:

list.append is a mutator method, meaning that unlike string methods which return the modified version of the string, this directly changes the list and returns None.


More about:

List mutability

Mutator methods

More mutator methods

Answered By: Ecko
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.