r/programminghelp • u/memeboi0312 • Apr 03 '21
Python Trying to make python print a random sentence from a sentence bank
I am making a discord bot that prints a sentence from a list of a txt file. I got a script working to pull a random word, but I don't know how to make python recognize a full sentence. Each sentence is separated by a period and indent in the file btw. Also this is my code:
with open("ozair quote.txt", "r") as file:
data = file.read()
words = data.split()
word_pos = random.randint(0, len(words)-1)
print(words[word_pos])
4
Upvotes
1
u/[deleted] Apr 03 '21
Try using .readlines()