Python Text File Programs

1.Create a text file “intro.txt” in python and ask the user to write a single line of text by user input.

def code():
    f = open("intro.txt","w")
    text=input("Enter the text:")
    f.write(text)
    f.close()
code()

Leave a Reply

Your email address will not be published. Required fields are marked *