Last active
March 26, 2020 08:06
-
-
Save ishank-dev/d839dab71710049061f6ae37cae0cb18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
'A' and 'I' are the only one letter word present in english language, | |
hence this algorithm concatenates the other single letters with the | |
next word in case they are anything other than 'A' or 'I'. | |
''' | |
def test(text): | |
list_words = text.split() | |
if len(list_words[0])==1: | |
if list_words[0] not in ['A','I']: | |
list_words[1] = list_words[0] + list_words[1] | |
list_words.pop(0) | |
updated_text = ' ' | |
updated_text = updated_text.join(list_words) | |
print(updated_text) | |
string = "W HEN they met at the house of the police" | |
string_one = "I am a boy" | |
string_two = "When I was young" | |
test(string) | |
test(string_one) | |
test(string_two) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment