python 决策_Python编程决策结构

通常,当我编程和使用决策结构(以及原始输入)时,我选择的答案会被忽略并转到第一个“if”语句并显示该语句的输出。在

在课堂上,我们必须使用循环和决策结构创建一个游戏。当我运行这个程序时,我经常遇到程序输出“if”语句的输出而不是用户选择的答案的问题。在

例如:score=0

while True:

optionOne=raw_input("Please pick one of the options!")

if (optionOne=="one" or "One" or "ONE"):

print "You have succesfully sneaked out without alerting your parents!"

print "Your current score is " + str(score)

break

elif (optionOne=="two" or "Two" or "TWO"):

print "Due to stress from work, your mom does not notice your lies and allows you to leave."

print "Your current score is " + str(score)

break

elif (optionOne=="three" or "Three" or "THREE"):

print "Your mom is understanding and allows you go to the party!"

score=score+10

print "You get 10 additional points for being honest!"

print "Your current score is " + str(score)

break

在这里,尽管用户选择了第二个选项,但使用了第一个“if”语句的输出。我搞不清是什么语法错误或错误,我犯了这一切发生。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值