【发布时间】:2020-01-07 03:57:59
【问题描述】:
我想知道如何将字符串值转换为 False 布尔值,因为每次运行代码时它都会返回 True 值。
high_income = input(“Do you have a high income?:”)
credit = input(“Do you have a credit line?”)
If high_income and credit:
Print(“eligible for loan”)
else:
print(“not eligible”)
【问题讨论】:
-
输入总是返回字符串,非空字符串总是给出
True- 你应该比较ie。high_income.lower() == 'yes' and credit.lower() == "yes"