QUESTION IMAGE
Question
complete the code.
import csv
infile = open(pets.txt,r)
myreader = reader(infile)
for item in myreader:
print(item)
Step1: Import the csv module
The import csv statement allows using csv - related functions.
Step2: Open the file
The open('pets.txt','r') function opens the text file in read mode.
Step3: Create a csv reader object
In Python's csv module, to create a reader object for reading from a file, we use csv.reader. So the missing part is csv.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
csv