I'm new to coding and have been trying to figure out why my code isn't working right.
credit_score = int(input('What is your credit score? '))
income = int(input('What is your annual income? '))
good_credit = credit_score>= 400
k = (20*50)
high_income = income>=250000
medium_income = high_income>income>= 70000
low_income = income<70000
if high_income and good_credit or medium_income and good_credit:
loan = True
if loan:
loan = 'approved'
else:
loan = 'not approved'
print(f'Your loan is {loan}')
The medium income variable falls between 70,000 and 250,000. What my code is supposed to do is return the string 'approved' when the inputted credit value is greater than or equal to 400 and the income falls between 70,000 and 250,000.
But every time I run it and put in the medium-income values it consistently returns 'not approved', which should only be returned if a low-income value is entered with a high credit value. However, if I enter a high credit value and a high-income value the code works just fine and returns 'approved'.
What is your credit score? 900
What is your annual income? 90000
Your loan is not approved?
With these values, it should return 'approved'
Any help is appreciated.
question from:
https://stackoverflow.com/questions/65921485/wrong-string-is-being-returned-on-a-range-of-values-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…