I'm fairly new to Python. Here's the code in 'file1'
phrases = []
buildWord = ""
file = open("words.txt")
words = file.read()
for i in words:
if(i == "\n"):
phrases.append(buildWord)
buildWord = ""
else:
buildWord += i
file.close()
Basically, there's a loop that gets all words in a file called 'words.txt' and appends them into a list called phrases. Now, in 'file2' I would like to simply import this phrases variable to use. Here's the code used in 'file2'
from 'file1' import phrases
This throws an error "no module named, is not a package". Why am I getting this error?
file1asfile1.pyand import it like:from file1 import phrases