You are on page 1of 2

PRACTICAL-11

Ques. Write a program to define function DISPLAYWORDS in pyhton to read


the lines from a text file POEM.TXT and display those words which are less tah
4 characters.
def DISPLAYWORDS():

c=0

file=open('POEM.txt','r')

line=file.read()

word=line.split()

for w in word :

if len(w)<4:

print(w)

file.close()

DISPLAYWORDS()

➢ POEM.TXT
She was like seeing the sun shine

in the pouring rain;

Something so beautifully uncommon,

that it made people notice


OUTPUT
She

was

the

sun

in

the

so

it

You might also like