Question: Create a python program that takes the text file we created in the last questions as a command line argument, opens it , and reads

Create a python program that takes the text file we created in the last questions as a command
line argument, opens it, and reads it. It should be named read.py.
This program should:
Take two files as command line arguments (read.py, myfile.txt)
Check for the number of arguments and exit with a message if there arent
exactly 2.
Open the text file for reading.
Print the sentence The farm has ___, for every animal in myfile.txt.
Close the file.
This program should take no input from the user but give an output.
Example Output:
The farm has cows
The farm has pigs
The farm has dogs
The farm has birds
The farm has cats

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!