Skip to main content
Just remove a not use whitespace
Link
frlan
  • 7.3k
  • 3
  • 36
  • 72

Python  : Lists for validation

Source Link

Python : Lists for validation

I'm trying to validate an input by using a list that holds the strings that are valid inputs but I can't seem to get it to work correctly, any help?

choice = ["A","a","B","b"]
def main():
    test = input()
    if validate(test):
        print("Entered a")
    else:
        print("did not enter a")

def validate(val):
    try: 
        val = choice.index[1]
    except:
        return False
    else:
        return True
main()