vendredi 7 mai 2021

random_word is returning 'None'. object of type 'NoneType' has no len()

I was using the random_word module in Python; however, it returns None. The issue isn't solving no matter what I do.

def main():
    word_range=7
    flag="White"
    while flag=="White":
        word=word_creator()
        if len(word)<=word_range and len(word)>=word_range-2:
            flag="Red"

whereas word_creator module is defined as

def word_creator():
    word1=r.get_random_word()
    if word1==None:
        word_creator()
    return (word1)



Aucun commentaire:

Enregistrer un commentaire