# File: printDogs.py # Author: Dr. Gibson # Date: 11/18/2017 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that opens a file called "goodDogs.txt", # and prints out 'X is a good dog' for each dog in the file. # The file is in the format of 'DOG NAME, DOG BREED' on each line. DOG_NAME = 0 DOG_BREED = 1 def main(): #1: open the file filename = "goodDogs.txt" ifp = open(filename, "r") #2: read the file in and print out "X is a good dog" for each dog dogList = ifp.readlines() for i in range(len(dogList)): dogInfo = dogList[i].split(",") print(dogInfo[DOG_NAME], "is a good dog") #3: finish using the file ifp.close() main()