问题遇到的现象和发生背景
在python中,将字符串True和False转化为布尔值True和False
代码
credit = input("Do you have good credit? True or False?")
if credit == "True":
good_credit = True
else:
good_credit = False
print(good_credit)
结果
Do you have good credit? True or False? True
False
Process finished with exit code 0
我想要达到的结果
当输入True时,good_credit为布尔值True
当输入False时,good_credit为布尔值False