Python Forum

Full Version: Learn Python 3 the Hard Way
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Have been trying to learn Python via a book called: Learn Python 3 the Hard Way, and thought i was doing really well until i came to exercise 15: Reading Files. I was on the verge of giving up because i could not get the script to work. I had been calling the script like so:
python3 ~/python_exp/ex15.py ex15_sample.txt and this only caused an Traceback error to be displayed. So finally i tried:
python3 ~/python_exp/ex15.py ~/python_exp/ex15_sample.txt and this worked!

Now when the script displayed the message correctly at the bottom was Try again, so i retyped:
python3 ~/python_exp/ex15.py ~/python_exp/ex15_sample.txt and got the following error message:

python3 ~/python_exp/ex15.py ~/python_exp/ex15_sample.txt
Traceback (most recent call last):
File "/home/oldDog/python_exp/ex15.py", line 17, in <module>
txt_again = open(file_again)
FileNotFoundError: [Errno 2] No such file or directory: 'python3 ~/python_exp/ex15.py ~/python_exp/ex15_sample.txt'
oldDog@my-desktop-ubuntu-mate:~$

Could someone tell me what is going on here please and what i've done wrong.

Thanks all
Post the code of ex15.py between code tags here. How to do it