Hello guys. I have an error that I can't quite fix. I am trying to create a program that will do the following things as of now.
1. open a file and read it.
2. put all the file's information in a list.
3. strip any percent characters from any words in the list.
4. print the list's length.
The problem that I get an IOError: no such file or directory (filename)
here is my code below.If you could, don't write code corrections, as copying coding styles could easily get me a zero on this assignment I am doing for school. Tell me if you can, what is wrong in plain English and tell me roughly what I need to do to correct it.
Thanks.
code:
def read_file(filename):
wordlist=[]
with open("{}".format(filename), "rb") as infile:
infile.read()
for line in file:
line.strip()
line.strip("%")
wordlist.append(line)
wordlist=set(wordlist)
print len(wordlist)
read_file("2of12inf.txt")
Pages 1