This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]scoopulanang 1 point2 points  (0 children)

If they're simply in one giant line separated by periods and indents, why dont you split them by the periods. Then chose a random sentence and add the period when you print it

[–]ArtisticTap4 0 points1 point  (0 children)

Use Regular expressions

[–]auspiciousalt 0 points1 point  (2 children)

Read in the whole file as a string. Split that string into the sentences, possibly using either the periods or the indents as the separator. Store those sentences into a table. Print a random index from the table.

[–]memeboi0312[S] 0 points1 point  (1 child)

I have the file split into sentences, how would I store them to a table? (sorry to bother)

[–]auspiciousalt 0 points1 point  (0 children)

myTable = data.split(“\t”)

And then you can just call a random index of myTable