import random
def generate_random_word(n, c):
if not c:
return "no"
random_word = ''.join(random.choice(c) for _ in range(n))
return random_word
# Example usage
n = 5
character_list = ['a', 'b', 'c', 'd', 'e']
random_word = generate_random_word(n, character_list)
print("Generated Word:", random_word)
In this example, if n is 5 and character_list contains the characters ['a', 'b', 'c', 'd', 'e'], the function will generate a random word of length 5 using these characters. If character_list is empty, it will return "no".