我试图制作python脚本/程序/任何东西。经过一些研究,我最终以这种方式工作了代码,但是后来我尝试将这些简单的输入:A和B更改为更复杂的内容,我在第二个代码中使用了Abel和Boris作为示例,但是该代码停止了按预期工作当我输入正确的答案时停止循环仍在运行,我知道它的问题可能是我做错了,但我无法弄清楚是什么,所以希望您能为我提供帮助。谢谢你的帮助。鲍里斯
此代码有效:
输入任何名称作为名称,当要求选择一侧时,请使用“ A”(或“ a”)或“ B”(或“ b”)进行编码,如果您使用其他任何名称,则会提示您再次
wrong=True
playername=input("Enter a name: ")
print("God said choose a side ",playername,", Side A or Side B?")
while wrong:
name=input("Enter a choice: ")
if name is("A")or name is("a"):
print("You said: A is THE chosen ONE")
wrong=False
if name is("b")or name is("B"):
print("You said: B is THE chosen ONE")
wrong=False
if wrong: print ("That side doesnt exist")
if name is ("C")or name is("c"):
print("So you are the new member of the A side. Go to the east.")
if name is ("b")or name is("B"):
print("So you are the new member of the B side. Go to the west.")
wait=True
while wait:
waitloop=("idk")
此代码无效:
我将“ A”(“ a”)和“ B”(“ b”)分别更改为“ Abel”(“ abel”)和“ Boris”(“ boris”),此后即使在正确之后它也开始循环播放答案(Abel / abel / Boris / boris)
wrong=True
playername=input("Enter a name: ")
print("God said choose a side ",playername,", Side A or Side B?")
while wrong:
name=input("Enter a choice: ")
if name is("Abel")or name is("abel"):
print("You said: ABEL is THE chosen ONE")
wrong=False
if name is("Boris")or name is("boris"):
print("You said: BORIS is THE chosen ONE")
wrong=False
if wrong: print ("That side doesnt exist")
if name is ("Abel")or name is("abel"):
print("So you are the new member of the ABEL side. Go to the east.")
if name is ("Boris")or name is("boris"):
print("So you are the new member of the BORIS side. Go to the west.")
wait=True
while wait:
waitloop=("idk")