织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

Return Tr欧博注册ue, False and None in Python

时间:2026-01-05 07:48来源: 作者:admin 点击: 1 次
It's impossible to say without seeing your actual code. Likely the reason is a code path through your function that doesn't execute a return statemen

It's impossible to say without seeing your actual code. Likely the reason is a code path through your function that doesn't execute a return statement. When the code goes down that path, the function ends with no value returned, and so returns None.

Updated: It sounds like your code looks like this:

def b(self, p, data): current = p if current.data == data: return True elif current.data == 1: return False else: self.b(current.next, data)

That else clause is your None path. You need to return the value that the recursive call returns:

else: return self.b(current.next, data)

BTW: using recursion for iterative programs like this is not a good idea in Python. Use iteration instead. Also, you have no clear termination condition.

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2026-01-06 02:01 最后登录:2026-01-06 02:01
栏目列表
推荐内容