I have to following python script: import re import string infile = open(‘story.txt’) str_story = infile.read() target = str_story lst =…

  

I have to following python script:import reimport stringinfile = open(‘story.txt’)str_story = infile.read()target = str_storylst = re.findall(r'(.+ )1′, str_story, flags=re.I)for val in lst: print(val)which prints:. in . . The Hooray! The . . . . . . and These are the redundant words in story.txt how do i remove the redundant word and not the entire match.group() here is the story.txt: THE THREE WISHES Once upon a time . . . a woodcutter lived happily with his wife in a prettylittle log cabin in the middle of a thick forest. Each morning he set off singing to work, and when he came home in the evening, a plate of hot steaming soup was always waiting for him. One day, however, he had a strange surprise. He came upon a big fir tree with strange open holes on the trunk. It looked somehow different from the other trees, and just as he was about to chop it down, the alarmed face of an elf popped out of a hole. “What’s all this banging?” asked the elf. “You’re not thinking of cutting down this tree, are you? It’s my home. I live here!” The woodcutter dropped his axe in astonlshment. “Well, I . . .” he stammered. “With all the other trees there are in this forest, you have to pick this one. Lucky I was in, or I would have found myself homeless.” Taken aback at these words, the woodcutter qulckly recovered, for after allthe elf was quite tiny, while he himself was a big hefty chap, and he boldly replied: “I’ll cut down any tree I like, so . . .” “All right! All right!” broke in the elf. “Shall we put it this way: if youdon’t cut down this tree, I grant you three wishes. Agreed?” The woodcutter scratched his head. “Three wishes, you say? Yes, I agree.” And he began to hack at another tree. As he worked and sweated at his task, the woodcutter kept thinking aboutthe magic wishes. “I’ll see what my wife thinks…” The the woodcutter’s wife was busily cleaning a pot outside the house when her husband arrived. Grabbing her round the waist, he twirled her in delight. “Hooray! Hooray! Our luck is in!” The the woman could not understand why her husband was so pleased with himself and she shrugged herself free. Later, however, over a glass of fine wine at the table, the woodcutter told his wife of his meeting with the elf, and she too began to picture the wonderful things that the elf’s three wishes might give them. The woodcutter’s wife took a first sip of wine from her husband’s glass. “Nice,” she said, smacking her lips. “I wish I had a string of sausages to go with it, though…” Instantly she bit her tongue, but too late. Out of the air appeared the sausages while the woodcutter stuttered with rage. “. . . what have you done! Sausages . . . You wasted a wish! I wish they would stick up your nose!” No sooner sald thandone. For the sausages leapt up and stuck fast to the end of the woman’s nose.This time, the woodcutter’s wife flew into a rage. “You idiot, what have you done? With all the things we could have wished for . . .” The mortified woodcutter, who had just repeated his wife’s own mistake, exclaimed: “I’d chop . . .” Luckily he stopped himself in time, realizing with horror that he’d been on the point of having his tongue chopped off. As his wife complained and blamed him, the poor man burst out laughing. “If only you knew how funny you look with those sausages on the end of yournose!” Now that really upset the woodcutter’s wife. She hadn’t thought of her looks. She tried to tug away the sausages but they would not budge. She pulled again and again, but in vain. The sausages were firmly attached to her nose. Terrified, she exclaimed: “They’ll be there for the rest of my life!” Feeling sorry for his wife and wondering how he could ever put up with a woman with such an awkward nose, the woodcutter said: “I’ll try.” Grasping thestring of sausages, he tugged with all his might. But he simply pulled his wife over on top of him. The pair sat on the floor, gazing sadly at each other. “What shall we do now?” they said, each thinking the same thought. “There’s only one thing we can do . . .” ventured the woodcutter’s wife timidly. “Yes, I’m afraid so . . .” her husband sighed, remembering their dreams of riches, and he bravely wished the third and last wish “I wish the sausages would leave my wife’s nose.” And they did. Instantly, husband and wife hugged each other tearfully, saying “Maybe we’ll be poor, but we’ll be happy again!” That evening, the only reminder of the woodcutter’s meeting with the elf was the string of sausages. So the couple fried them, gloomily thinking of what that meal had cost them. Computer Science Engineering & Technology Python Programming CSC 131

Don't use plagiarized sources. Get Your Custom Essay on
I have to following python script: import re import string infile = open(‘story.txt’) str_story = infile.read() target = str_story lst =…
Just from $13/Page
Order Essay
  

Leave a Reply

Your email address will not be published.

Related Post

Open chat
💬 Need help?
Hello 👋
Can we help you?