有没有更好的方法来检查一系列输入是否符合某个停止条件?

Is there a better way to check if a series of inputs match a certain stop condition?

(Python 3.7)

我有一个与下面包含的程序类似的程序。我只是想弄清楚是否有更好的方法来检查是否有任何用户输入符合“结束”条件,我确实需要分别保存每个输入。

while True:
    fname = input("Enter Customer first name: ")
    if fname == "end":
        break
    
    lname = input("Enter Customer last name: ")
    if lname == "end":
        break

    email = input("Enter Customer email: ")
    if email == "end":
        break

    num = input("Enter Customer id: ")
    if num == "end":
        break
    elif not num.isdigit():
        num = -1
    # not worried about error here
    num = int(num)

    print(fname, lname, email, num)
print("User has ended program")

我不担心现阶段的错误,只是想在这里就最干净的实施进行头脑风暴。我会有很多输入,所以我希望我不必为每个单独的输入一遍又一遍地包含相同的 if 语句。

这将是创建用户例外的好机会:

class UserExit(BaseException):
    pass

def get_input(prompt):
    response = input(prompt)
    if response=="end":
        raise UserExit("User Exit.")
    return response

try:
    while True:
        fname = get_input("Enter Customer first name: ")
        lname = get_input("Enter Customer last name: ")
        email = get_input("Enter Customer email: ")
        num = get_input("Enter Customer id:")
        if not num.isdigit():
            num = -1
        else:
            num = int(num)
        print (fname,lname,email,num)

except UserExit as e:
    print ("User ended program.")