Reputation: 27
def sentence_checker(phrase):
capital = phrase.capitalize()
question_words = ('How', 'What', 'Why', 'When', 'Who', 'Which', 'Whose', 'Whom')
if phrase.startswith(question_words):
return '{}?'.format(capital)
else:
return '{}.'.format(capital)
while True:
sentence = input('Say Something: ')
sentence = sentence
if sentence == '\end':
break
else:
listlist.append(sentence_checker(sentence))
print(' '.join(listlist))
I am a beginner in python. This code recognises all the words except 'How'. This is the output:
Say Something: how
Say Something: \end
How.
Upvotes: 0
Views: 80
Reputation: 335
In fact, the only was problem was indeed (as commented) that you were using phrase
, rather than capital
.
Upvotes: 1