write a function word(2) in python that displays 2 letter words present in a text file 'myfile.txt'.
if the 'myfile.txt' content are as :
we are here to learn python.python has so many features which make it more comfortable interface.
output:
to
so
it
Answers
Answered by
4
This should work. I just tested it on my pc.
def my_word():
global word
with open("myfile.txt") as f:
lines = f.readlines()
for line in lines:
words = [word for word in line.split() if len(word) == 2]
print(words)
print(my_word())
Please mark as the brainliest
Similar questions
Hindi,
10 days ago
Computer Science,
10 days ago
English,
20 days ago
Math,
8 months ago
Science,
8 months ago