python-3.x 我的编码之旅的开始,2几个小时后,3我如何限制第二行的输入为整数(从1到1000)?

oogrdqng  于 2022-12-14  发布在  Python
关注(0)|答案(1)|浏览(97)
mortgage = 153000
credit_score = input ("What's your credit score? ") # here I want to limit the input to integers (1-1000).
if int(credit_score) >= 650:
    mortgage_payment = mortgage * 0.25
else:
    mortgage_payment= mortgage * 0.28
print (f'Your mortgage payment will be: ${mortgage_payment}')

因为这只是一个开始,我还在看教程如何编码和学习沿着,并试图使事情更有趣+更复杂。:)

lb3vh1jj

lb3vh1jj1#

mortgage = 153000
credit_score = input ("What's your credit score? ") # here I want to limit the input to integers (1-1000).
if int(credit_score) >= 650 and credit_score in range(1,10001):
    mortgage_payment = mortgage * 0.25
else:
    mortgage_payment= mortgage * 0.28
print (f'Your mortgage payment will be: ${mortgage_payment}')

相关问题