我创建了一个列表,因此如果有人输入列表中的任何项目,它将打印相同的内容。
lista = ["example", "example2"]
listb = ["exampleb", "example2b"]
choice = input()
if choice == lista[]:
print("outputa")
elif choice == listb[]:
print("outputb")
如果用户键入 example 或 example2,它将打印 outputa,但如果用户键入 exampleb 或 example2b,它将打印 outputb。 谢谢
请您参考如下方法:
lista = ["example", "example2"]
listb = ["exampleb", "example2b"]
choice = input()
if choice in lista:
print("outputa")
elif choice in listb:
print("outputb")
