File problem 1.
Write a function named stringsToFile() that opens a file for writing and writes a list of strings to the file, with each element of the list written to a line. Hint: use a for loop to iterate over the list of strings and write them to the file.
Input (two parameters):
* filename -- name of file to open for writing * strlist -- a list of string to write to filename
An example of how to call stringToFile() is:
s0 = 'You are old Father William, the young man said,' s1 = 'And your hair has become very white;'
s2 = 'And yet you incessantly stand on your head--'
s3 = 'Do you think, at your age, it is right?'
lst = [s0, s1, s2, s3]
stringsToFile('FatherWilliam.txt', lst)
pakiali007 0 Newbie Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.