布尔表达式本身的问题在于它们始终为True。
if a == 'b' or 'c'就像
if (True|False) or'c',并且由于
'c'是true,所以不管第一个表达式(
a == 'b')都是True 。
您要么想要,
a == 'b' and a == 'c'…要么更简洁
a in {'b', 'c'…},它检查是否a是集合的成员。
如果要循环,请使用循环:)
while username not in {"cking", "doneal", "mcook"}: print ("Invalid username. Please try again.") username = input ("Enter username:")print ("Valid username.")


