Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 22 Online
OpenStudy (anonymous):

I wanted to see if the load words function would work in python 3.2, the code is below, and the text file is in the same folder as the code. def load_words(): print("Loading word list from file...") # inFile: file inFile = open(WORDLIST_FILENAME, 'r', 0) # wordlist: list of strings wordlist = [] for line in inFile: wordlist.append(line.strip().lower()) print(" ", len(wordlist), "words loaded.") return wordlist Yet all I get in return is the error message: builtins.ValueError: can't have unbuffered text I/O

OpenStudy (anonymous):

Change 'r' to 'rb', I believe.

OpenStudy (anonymous):

in the inFile?

OpenStudy (anonymous):

In the text file given for problem set 3, the text file provided has no spaces between it's words. I think this will mess up the whole entire process, right?

OpenStudy (anonymous):

Yes, in the inFile.

OpenStudy (anonymous):

As for the text file, yes, you're absolutely right. Go download the solution file and steal the text file from there. And don't peek at anything else. :)

OpenStudy (anonymous):

Thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!