You are on page 1of 1

PRACTICAL ASSIGNMENT-7

DATE:

Q.WAP IN PYTHON to input text in a file source.txt and display it in word wise reverse manner

f=open('source.txt','w')
f1=open('target.txt','w')
data=input('enter the text...')
f.write(data)
f.close()
f=open('source.txt','r')
x=f.read()
y=x.split()
z=''
for i in range(len(y)):
z=z+y[-i-1]+'.'
f.close()
f1.write(z)
f1.close()
print('Orignal data')
print(data)
print('Reversed data')
print(z)
Output:

You might also like