-3
我完全不熟悉Python和編碼。我需要編寫一個允許用戶輸入許多行的代碼,當他們完成編寫多個句子時,他們輸入一段時間來停止程序,然後程序會告訴用戶輸入了多少個單詞。我會如何去做這件事?來自用戶的字數
這是我到目前爲止有:
print("Enter as many lines of text as you want.")
print("When you're done, enter a single period on a line by itself.")
while True:
print("> ", end="")
line = input()
if line == ".":
break
totalWords = line.split()
newWords = totalWords.append(line)
wordCount = len(newWords)
print("The number of words entered:" , wordCount, "")
「我想要X」類型的「問題」以及誰幫助我不喜歡我們在這裏,在這裏您必須展示您已經嘗試了什麼以及您遇到了哪些問題,因此我們將幫助您提供建議或可能的解決方案 – eyllanesc
問題要求作業幫助必須包括迄今爲止解決問題所做的工作摘要,以及描述您解決問題的難度。 - https://stackoverflow.com/help/on-topic – skrx
我建議您閱讀以下內容以改善您的問題:[我如何問一個好問題?](https://stackoverflow.com/help/how-to - 問) – eyllanesc