【发布时间】:2016-04-20 12:53:46
【问题描述】:
我需要知道字母 b(最好是大写和小写)是否包含在一个列表中。
我的代码:
List1=['apple', 'banana', 'Baboon', 'Charlie']
if 'b' in List1 or 'B' in List1:
count_low = List1.count('b')
count_high = List1.count('B')
count_total = count_low + count_high
print "The letter b appears:", count_total, "times."
else:
print "it did not work"
【问题讨论】:
标签: python list search substring