CBSE Class 12 Computer Science
Question 70 of 136
Data File Handling — Question 9
Back to all questionsfileout = open('STRS.txt', 'w')
ans = 'y'
while ans == 'y':
string = input("Enter a string: ")
fileout.write(string + "\n")
ans = input("Want to enter more strings?(y/n)...")
fileout.close()Enter a string: Hello
Want to enter more strings?(y/n)...y
Enter a string: World!
Want to enter more strings?(y/n)...n
The file "STRS.txt" includes:
Hello
World!