【发布时间】:2022-11-11 06:30:45
【问题描述】:
如何制作 = 2(有两个“the”)
import re
text = "there are a lot of the cats"
o = re.findall("the", text)
print(o)
def text(word):
count = 0
for word in text:
if "ou" in text:
count += 1
return count
print(count)
print(i)
此代码应返回 2(因为有 2 个“the”)
【问题讨论】:
-
您可以使用简单的
len(text)获得字母计数,并且要获得每个字母,您可以编写一个简单的 for 循环for letter in text: print(letter) -
你需要数字母或单词吗?
-
print(len(o))不是您要找的东西吗?