【发布时间】:2014-11-03 14:38:41
【问题描述】:
在我的关卡编辑程序中,我有以下代码,用于删除已移出可玩区域的游戏片段:
x, y = theobj.pos
if x not in range(0,79):
level.remove_obj(theobj)
if y not in range(0,29):
level.remove_obj(theobj)
有没有什么有效的方法可以将它简化为一个 if 语句?我考虑过使用列表推导来生成所有有效位置元组的列表,但这似乎有点臃肿。
【问题讨论】:
标签: python python-3.x comparison-operators