Leonardo Sotelo

Generation

generate functionTue, 30 May 2023

funtion that generate random words with random length using only letters

import random #this function takes a random word from a list and capitalize it def random_words(words): return random.choice(words).capitalize() #this function makes a random lenght def length(words): return len(random_words(words)) #this function counts how many times the letter 'a' apears in the random word def count_a(words): sum = 0 for i in random_words(words): if i == 'a': sum = sum + 1 return sum #this function makes a list of random words with random lenght def random_list(words): list = [] for i in range(10): list.append(random_words(words)) return list #this function counts how many times the letter 'a' apears in the random word def count_a(words): sum = 0 for i in random_words(words): if i == 'a': sum = sum + 1 return sum #this

Javascript
Generate More

Want to kickstart your project?Use the new AI Studio to create your code