+ 1

How to convert the text in text file into a list to append it...ect

Hey, I'm trying to make a program that can search for stuff which is located in a text file, I thought of turning the text into a list(s) so I can define a function to search for keywords in that list. ( if there's a better way to make such code let me know, I'm still a beginner in python )

6th Mar 2019, 8:55 PM
Aesthe
Aesthe - avatar
2 Answers
+ 4
if your text is imported as a string called text, you can use: mylist = text.split() mylist is then a list of all the space separated words from the text. If you try something, post your code here to make it easier to help you :-)
6th Mar 2019, 11:33 PM
CĂ©pagrave
CĂ©pagrave - avatar
+ 1
Alright, thanks! I'll share my code here when I finish it. Thanks once again.
7th Mar 2019, 8:04 AM
Aesthe
Aesthe - avatar