Important Python Mcqs

Which function is used to write a list of string in a file?

a) writeline()

b) writelines()

c) writestatement()

d) writefullline()

Answer

a) writeline()

Explanation

With the writeline() function you can write a list of strings to a file!

fh = open ("hello.txt", "w") 
lines_of_text =["a line of text", "another line of text", "a third line"] 
fh.writelines (lines_of_text)
Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?