为什么出现none啊
课后习题:def draft(x, y):
count = 0
length = len(y)
if x not in y:
print('no existence')
else:
for i in range(length-1):
if y == x and y == x:
count += 1
print(count)
print(draft(x = 'im', y='You cannot improve your past, but you can improve your future. Once time is wasted, life is wasted.'))
输出结果:
3
none
为什么出现这个none?
你的函数,没有return值,用print打印的话就是none
所以没有return,直接调用函数就行了,不需要print这个函数,函数里已经写了print
页:
[1]