Hangman Solution

The solution for Hangman shows error that it cannot find file “dictionary.txt”. this is what the terminal shows :

ruby lib/hangman.rb

Guesser: Computer (yes/no)? yes
lib/hangman.rb:98:in readlines': No such file or directory @ rb_sysopen - dictionary.txt (Errno::ENOENT) from lib/hangman.rb:98:inplayer_with_dict_file’
from lib/hangman.rb:185:in `’

I am running the file exactly how I downloaded, I didn’t change anything in the file.

it’s difficult to guess without seeing your code for reading the txt file
did you provide the full directory of the txt file instead of the relative path

Hi!

I just downloaded the solution and it seems to be running fine locally.

Is it possible you accidentally modified the file? Try re-downloading the zip and seeing if it works with a fresh copy.

Let us know how it works out!

best,
-Shalin
Hacker in Residence, NYC

I figured it out why it was happening.

I typed : ruby lib/hangman.rb

instead of :

cd lib
ruby hangman.rb

So it was looking for a file name “dictionary.txt” outside the lib directory.