Python

Swap the two file lines from one to one using python

Input:
     create two txt files

Output:
     interchange the lines of two file.(i.e.)sample txt file lines is stored to sample2.txt file

Program:

a=open("sample.txt")
x=a . read()
print(x)
a . close()
b=open("sample2 . txt")
y=b . read()
print(y)
b . close()
c=open("sample . txt" , "w")
c=write(y)
print(c)
c . close()
d=open("sample2 . txt" , "w")
d . write(x)
print(d)
d . close()

Comments

Popular posts from this blog

Software Freedom Day 2020

Factorial