Ending Up whole sentence


#1

code :
pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
word = original.lower()
first = word[0]
new_word = word+first+pyg
new_word=new_word[1:len(new_word)]
else:
print 'empty'

This is just for fun :
Is it possible that i could write the whole sentence and translate it ,not word by word ?
If anyone knows how , please tell me
Thanks in advance


#2

Well you could take the sentence and turn it into a list. Then take each element of the list and let it go through the same process ^^


#3

i did not understand anything you said ... :sweat:


#4

You take the sentence, and add all letters up until a space comes (that will become one word) and add that word to a list.

text = raw_input()
string = ""
liste = []
pyg = 'ay'
for element in text:
    if element != " ":
        string += element
    else:
        liste.append(string)
        string = ""

for original in liste:
    if len(original) > 0 and original.isalpha():
        word = original.lower()
        first = word[0]
        new_word = word+first+pyg
        new_word=new_word[1:len(new_word)]
        print new_word
    else:
        print 'empty'

#5

Put a space at the end of the sentence and the program should work fine :slightly_smiling:

I hope you understand now, what I meant :grin: