【发布时间】:2020-12-14 17:26:43
【问题描述】:
我正在尝试设置一个使用“或”两个条件的 while not 循环。本质上,我要求用户输入贷款类型,如果没有输入两个贷款之一,它会打印出它不是有效的贷款类型并再次要求输入。但是,我的代码仅适用于第一个条件,而第二个条件被忽略。
下面是我的代码:
loan = input('Enter the type of mortgage loan for the purchase of this property: \n').lower() #Asks for the type of mortgage loan
while not loan == 'fha' or loan == 'conventional': #Checks if input is fha or conventional, if not asks for input again
print("Sorry, that is not a valid loan type.")
loan = input('Enter the type of mortgage loan for the purchase of this property: \n').lower()
感谢您的帮助!
【问题讨论】:
标签: python while-loop conditional-statements