<分区> 分区>
我有一个字符串,说 Welcome to this world。我需要计算字符 w 的出现次数,忽略大小写。
x = "Welcome to this world"
list = x.split()
print(list)
a = []
for i in list:
a.append(i.count("w"))
else:
print(a)
Output: ['Welcome', 'to', 'this', 'world'] [0,0,0,1]
这将输出作为 [0,0,0,1] 但我希望它是 [1,0,0,1] 如果 w 被忽略。我应该做出哪些改变?
