Q. Write a program that copies one file to another. Have the program read the file names from user ?


You can understand by Watching video :-



Answer :-

file1 = input("Enter the name of original file :- ")
file2 = input("Enter the name of New file :- : ")

old = open( file1 , "r")
new = open( file2, "w")

data = old.read()
new.write( data )

print(" Program run successfully ")

old.close()
new.close()

Story.txt Contains :-

A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets & numbers are allowed in password.
This is Path Walla Website.

Output :-

Enter the name of original file :- story.txt
Enter the name of New file :- : Path Walla.txt
 Program run successfully

>>>

Path Walla.txt Contains :-

A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets & numbers are allowed in password.
This is Path Walla Website.

1 Comments

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

  1. दूसरी लाइन में file की जगह पर "old file. txt" क्यों नहीं है

    ReplyDelete

Post a Comment

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

Previous Post Next Post