我正在制作一个程序,如果使用“通过”这个词,它会拒绝任何东西;可以是大写或小写字母
也就是说,如果正在使用pAss或pAss这个词
它也不能与addass
或fhsaPasS
等其他单词一起使用
例如,我的输入是asdapaSS,然后被拒绝
条件是“不包含任何大小写字符组合中的字符串”pass“
下面的代码是我现在已经想到的
input1 = input("Please write a word: ")
lowercase = input1.lower()
if len(lowercase) == "pass":
print("False")
else:
print("True")
这段代码使用正则表达式库检查刚刚输入的字符串的小写版本中是否没有“pass”。从正则表达式库中使用findall来解决这个问题
您可以在operator中使用:
相关问题 更多 >
编程相关推荐