为什么这样不行
rank=input("Is the realm a duchy, kingdom or empire? ")
if rank=="duchy"or"Duchy":
realm=input("What is the duchy named? ")
elif rank=="kingdom"or"Kingdom":
realm=input("What is the kingdom named? ")
elif rank=="empire"or"Empire":
realm=input("What is the empire named? ")
else:
print("Restart and say duchy, kingdom or empire. ")
不管我怎么回答,都有人问我公爵叫什么名字
代码中的错误在
if statement
:所以,不管你的
rank
是什么,or "duchy"
都会使它成为True
。您有许多解决方案可以解决此问题:它计算
if "Dutchy"
,返回True
你需要
或者更好
相关问题 更多 >
编程相关推荐