Geetha, the English teacher was teaching about the articles in English
grammar. She decided to play a game with the students in which a
phrase or a sentence will be provided to the students, and they should
rewrite the given sentence after removing all the articles wherever
they may be present.
Write a program to find the correct answer for each sentence she
provides
Articles are'a', 'an', and 'the'.
Input format
Input is in the format of a string (character array).
Output format
Output is the input string in which all the articles are removed.
Sample testcases
Input 1
Output 1
Provide Cus
Fun Republic or
The Dhillon Theatre, is an Fun Repul Dhillon tre is
1
9
28
Answers
Answer:
hgastbvxdffuhhcfdiijbvcdd
I assume that the input consists of multiple sentences separated by periods, and the program should remove all the articles from each sentence. Here's a Python program that does that:
def remove_articles(text):
articles = ['a', 'an', 'the']
sentences = text.split('.')
result = []
for sentence in sentences:
words = sentence.split()
new_words = []
for a word in words:
if word.lower() not in articles:
new_words.append(word)
new_sentence = ' '.join(new_words)
result.append(new_sentence)
return '.'.join(result)
We first define a list of articles, and then split the input text into sentences using the period as a separator. We then loop through each sentence, split it into words, and check if each word is an article (ignoring case).
Finally, we join the list of words back into a sentence and append it to a list of results. We join the list of results back into a string using periods as separators.
Here's an example usage of the program:
text = "Provide Cus Fun Republic or The Dhillon Theatre, is a Fun Repul Dhillon there is."
result = remove_articles(text)
print(result)
#SPJ3