Computer Science

Which of the following is not a correct Python statement to open a text file "Notes.txt" to write content into it ?

  1. F = open('Notes.txt', 'w')
  2. F = open('Notes.txt., 'a')
  3. F = open('Notes.txt', 'A')
  4. F = open('Notes.txt', 'w+')

Python File Handling

3 Likes

Answer

F = open('Notes.txt', 'A')

Reason — F = open('Notes.txt', 'A'), in this statement mode should be written in small letter 'a'. So the correct statement would be F = open('Notes.txt', 'a').

Answered By

2 Likes


Related Questions