Q. Write a code snippet that will create an object called fileout for writing, associate it with the filename STRS. The code should keep on writing strings to it as long as the user wants.


Answer =


def fileout() :
    f = open("STRS.txt","w")
    while True :
        data = input("Enter any thing :- ")
        f.write (data + "\n")
        user = input("Do you want to enter more data (yes/no)")
        if user == "No" or user == "no" :
            break
    f.close()

fileout()



Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post