Random Word Generator

  • Share this:

Code introduction


This function generates a specified number of random words, with each word's length specified by the user.


Technology Stack : The function uses the built-in libraries random and string, but does not directly use any packages from the Babel third-party library.

Code Type : Function

Code Difficulty : Intermediate


                
                    
def random_word_generator(num_words, word_length):
    import random
    import string

    def generate_word(word_length):
        return ''.join(random.choice(string.ascii_lowercase) for _ in range(word_length))

    return [generate_word(word_length) for _ in range(num_words)]