************ CODE STARTS *******************
L1 = [] # create an empty list
L2 = [] # and another one
import os
def exists('/Users/username/Documents/python/word_bank.txt'):
return os.access('/Users/usernameDocuments/python/word_bank.txt', os.F_OK)
for line in open('/Users/username/Documents/python/word_bank.txt').readlines(): L1.append(line) # empty the word bank into a list
for i in range(len(L1)): # trim off the newlines
L1[i] [:-1]
import random
random.shuffle(L1) # shuffle the words
L1[0:3]
************ CODE ENDS **********************
Two problems have appeared:
1. I get a "syntax error" message at the line that starts with "def exists", but I don't see the mistake.
2. If I take out that line, I get "errno 2" at the next line; the interpreter seems convinced that that file doesn't exist, though it does. I actually tried putting os.path.exists() into the interpreter, and it returned 'true', but it still doesn't see the file when I try to run this program.
How can I solve or circumvent these problems? I appreciate any help, even hints, but frankly if anyone's willing to explain the solution outright I'd be grateful.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor