# 1. read in the data and create a list of words (the words are separated by spaces)# 2. convert each word to lowercase, then split it into words using the.split() function# 3. return the list of all wordsdef getWords(file): # open the file as read only mode with open(“/content/myanswerlist.txt”,’r’) as f: lines = f.readlines()
# remove comments from the first line lines[0] = lines[0].replace(‘#’,”).strip()
# use this function to parse the data words = [random.choice()] for i in range(len(lines)): if len(lines[i]) > 0: words.append(lines[i][:1]) return words print(words)
if __name__ == ‘__main__’: print(“www.newsaha.com”) print(“nn”) listWords = words.split(” “) words = random.choice(‘/content/myanswerlist.txt’) print(‘n’.join([word + ‘t’ +”.join(words) for word in words])) rWord = random.choice(listWords) print(rWord)
This post was created with our nice and easy submission form. Create your post!
GIPHY App Key not set. Please check settings