我在做什么,现在正在计数的空格数,再加入1
但如果用户输入类似"heres a big space______amazing right?"
程序会计算所有的6位和比方说,有10个字时实际上它是6计数字符串中的单词的数量
phrase = raw_input("Enter a phrase: ")
space_total = 0
for ch in phrase:
if ch == " ":
space_total += 1
words = space_total + 1
print "there are", words, "in the sentence"
好的,它工作。非常感谢!! –