Programming Exercise 3-1
Programming Exercise 6-4
def main():
# Declare variables
line = ”
counter = 0
# Open names.txt file for reading
infile = open(‘names.txt’, ‘r’)
# Priming read
line = infile.readline()
# Read in until no more data
while line != ”:
counter += 1
line = infile.readline()
# Close file
infile.close()
# Display the number of names in the file
print (counter, ‘names were read.’)
# Call the main function.
main()