Computer Science

What is the following code doing?

import csv
File = open("contacts.csv", "a")
Name = input("Please enter name: ")
Phno = input("Please enter phone number: ") 
data = [Name, Phno]
csvwriter = csv.writer(File)
csvwriter.writerow(data)
File.close()

Python Data Handling

1 Like

Answer

The code imports the CSV module, opens 'contacts.csv' in append mode, prompts the user for input of a name and phone number, writes data to the CSV file, and then closes the file.

Answered By

2 Likes


Related Questions