<分区> 分区>
我有点好奇下面的代码中是否遗漏了什么
我希望用户输入 "Y" 或 "H" 或 "E" 的逻辑,我想使用 return 语句转移到另一个类。如果不是,我使用 else 部分返回 bool 值 False。
有一个 while 循环会将控件发送回同一函数,直到用户输入所需的值。
在运行程序时,无论收到什么输入,它都不会进入 else 部分。
def getUserIngameOption(self):
userIngameOption=raw_input("Please Enter Y -> for Turn | H -> Hint | E -> to End")
userDesc=userIngameOption.upper()
if not ( userDesc==("Y") or ("H") or ("E")):
print "Mate PLEASE JUST TYPE WHATTTT is asked for !! not this",userDesc
return False
else:
self.userOpt=userDesc
print "This is detail that you got>>>",self.userOpt
return self.userOpt
