这是我到目前为止所拥有的:
while len(words) != 5:
words = raw_input("Enter a 5 worded sentence: ").split()
print "Try again. The word count is:", wordCount
if len(words) == 5:
print "Good! The word count is 5!"
问题是我明白了:
Enter a 5 worded sentence: d d d d
Try again. The word count is: 4
Enter a 5 worded sentence: d d d d d d
Try again. The word count is: 4
Enter a 5 worded sentence: d d d d d
Try again. The word count is: 4
Good! The word count is 5!
当我输入多于或少于 5 个字时,它会保持该字数并且不会改变。