- 编程
p1560是这样写吗?
- 2022-11-4 16:33:40 @
p1560是这样写吗?
def ensure(condition, message):
if condition:
print('*** 测试成功')
else:
print('*** 测试失败:', message)
def count_string(string, char):
a = 0
for i in range(len(string)):
if string[i] == char:
a = a + 1
return a
def test_count_string():
ensure(count_string('hello', 'l') == 2, 'test count string 1')
ensure(count_string('wonder', 'n') == 1, 'test count string 2')
ensure(count_string('wonder', 'h') == 0, 'test count string 3')
test_count_string()
1 条评论
-
掉榜模式 (王靖翔) LV 7 @ 2022-11-6 11:41:44
看看有没有 AC
- 1