mangafas mangafas - 3 months ago 8
Python Question

how to define a set of variables so the program responds in any of the items in a list is called, python3

I create a list so if someones inputs any item from the list it will print the same.

lista = ["example", "example2"]
listb = ["exampleb", "example2b"]
choice = input()
if choice == lista[]:
print("outputa")
elif choice == listb[]:
print("outputb")


if the user types either example or example2 it will print outputa but if the user types exampleb or example2b it will print outputb.
Thanks

Answer

Use:

if choice in lista:
    print("a")
elif choice in listb:
    print("b")

`