如输入: This is a Python program. 输出:There are 5 words in the line

输入一行字符,统计其中有多少个单词,每两个单词之间以空格隔开。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-天际的海浪 2021-06-08 18:18关注
代码如下:{如果对你有帮助,可以给我个采纳吗,谢谢!! 点击我这个回答右上方的【采纳】按钮}。
s = input('请输入一行字符:') li = s.split(" ") n = len(li) print(f"There are {n} words in the line")
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 9无用 7