I'm new to Python and I'm having a problem I can't explain. While running:

>>> open('word.txt')

it returns: No such file or directory: 'words.txt', even if I have both files saved in the same place.

I've tried entering the entire file location, but still no luck.

Any help would be greatly appreciated, and thank you very much for your time

Is it as simple as word.txt versus words.txt?

Try this:

import os
os.listdir('.')

If that gets an unexpected result, it should give you a good clue.

If you run your Python code from the shell, you will most likely not be in the same directory as your file word.txt

Give this a try to show the current working directory the shell looks at ...

>>> import os; os.getcwd()
'C:\\Python26'
>>>

Also, if you use Unix, file names and path names are case sensitive.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.