If you are writing data to a CSV file and want to ensure that no extra blank…

2026

If you are writing data to a CSV file and want to ensure that no extra blank lines are inserted between rows on Windows systems, which parameter should you include in the open() function?

  1. A.

    newline=''

  2. B.

    space=False

  3. C.

    mode='csv'

  4. D.

    encoding='utf-8'

Attempted by 84 students.

Show answer & explanation

Correct answer: A

When writing CSV files in Python, you must set newline='' when opening the file. On Windows systems, omitting this parameter causes Python to translate line endings automatically, which results in extra blank lines between rows when using the csv module. Setting newline='' disables this translation, ensuring consistent line breaks across platforms.

Explore the full course: Rssb Senior Computer Instructor