From c0abc984deeb8d1a68b18a97de72a41a6e409072 Mon Sep 17 00:00:00 2001 From: Vincent Chan Date: Wed, 17 Jun 2026 14:46:55 +0800 Subject: [PATCH] Fix last_floor validation: reject 0 to match error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Interactive input rejected `< 0`, but `str.isdigit()` already excludes negatives, so that branch was dead code and `0` slipped through despite the message stating "必须为大于0的整数". Validate `< 1` so the check matches the message and disallows a meaningless floor 0. Co-Authored-By: Claude Opus 4.8 (1M context) --- lottery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lottery.py b/lottery.py index cd198a4..8fc2d7f 100644 --- a/lottery.py +++ b/lottery.py @@ -181,7 +181,7 @@ def get_interactive_input(): last_floor = input("请输入参与抽奖的最后楼层(可选,直接回车使用所有楼层): ") if last_floor: - if not last_floor.isdigit() or int(last_floor) < 0: + if not last_floor.isdigit() or int(last_floor) < 1: print("错误: 最后楼层必须为大于0的整数") continue last_floor = int(last_floor)