mercredi 11 décembre 2019

Python. Is there a way to use is.digit method but only allow a certain range of numbers to be entered?

def main():
    userInput = input("Enter license plate tag: ")
    while(not validateTag(userInput)):
        print("INVALID ID: Try again")
        userInput = input("Please reenter your license plate tag: ")
    for char in userInput:
        charToWord(char)

    if (userInput[0:2].isalpha() and userInput[3:5].isdigit()):
        print("Big County")
    elif (userInput[0:1].isdigit() and userInput[2] == '-' and userInput[3:].isalnum()):
        print("Small County")
    else:
        print("vanity plate")

Above is a copy of my main function. I need to be able to take the following line:

elif (userInput[0:1].isdigit() and userInput[2] == '-' and userInput[3:].isalnum()):
        print("Small County")

And have it only be true if the digits entered for [0:1] are only between the numbers 3-97. Any suggestions on how to do that? Thank you.

Aucun commentaire:

Enregistrer un commentaire