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'.

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. 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 .

    ReplyDelete
    Replies
    1. No, because if you are not using CSV ' statement in your program then contacts.csv will treat as text file.

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post