English

Explain the use of output function write() with an example.

Advertisements
Advertisements

Question

Explain the use of output function write() with an example.

Code Writing
Explain
Advertisements

Solution

write(): Writes one string. It does not add a newline automatically.

with open("data.txt", "w") as file:
    file.write("First line\n")
shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Data File Handling - EXERCISE [Page 145]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 7 Data File Handling
EXERCISE | Q 9. a. | Page 145
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×