I am having trouble trying to figure out how to import text from a text file easily or at least a memorable method. I am trying to make a program that insults the user (for school), that brings in a word/s from one text file, adds another word/s from the second file and the final word/s from the third text file…
I am having trouble finding a way of coding to do this…I have the random number up and running to pick the text I just need to know how to access strings or text in a text file.
The easiest way is to use the
withstatement. It takes care of closing the file for you.Or read the data into directly into a list: