Q. What is following code doing?
file = open("contacts.csv", "a")
name = input("Please enter name: ")
phno = input("Please enter phone number.")
file.write (name + "," + phone + "\n")
Answer =
It will take data from user and write data in file 'contacts.csv'.
Should this show an error because in csc it is necessary to import csv plus there is no write() in csv there is a csv.writer() and writerow function .
ReplyDeleteNo, because if you are not using CSV ' statement in your program then contacts.csv will treat as text file.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )