Always true when testing if string == various OR'ed alternatives

前端 未结 5 1660
时光取名叫无心
时光取名叫无心 2020-11-30 14:57

So the problem I am currently having is that my program always calls the \'md5cypher\' class which I have defined, even if the input is not in that list:

def         


        
5条回答
  •  暖寄归人
    2020-11-30 15:36

    In reality you're checking:

    if (toe=='md5') or 'M' or 'm' or....
    

    And since bool('M') is True, you will always succeed that check. Try this instead:

    if toe.lower() in ('md5', 'm'):
    

提交回复
热议问题