저는 정말 프로그래밍에 익숙하지 않으며이 코드는 저를 괴롭 히고 있습니다.For 루프가 제대로 작동하지 않습니다.
def run():
print('Please enter how many month you want to calculate.')
month = int(sys.stdin.readline())
print('Please enter how much money you earn every month.')
income = int(sys.stdin.readline())
print('Please enter how much money you spend each month.')
spend = int(sys.stdin.readline())
month = month + 1
for month in range(1, month):
balance = (income * month) - spend
print('The next month you will have %s.' % balance)
난 당신이 wach 월 적립 얼마나 많은 돈을 계산하는 작은 프로그램을 만들기 위해 노력하고 있지만, 출력은 내가 원하는처럼되지 않습니다!
>>> run()
Please enter how many month you want to calculate.
5
Please enter how much money you earn every month.
100
Please enter how much money you spend each month.
50
The next month you will have 50.
The next month you will have 150.
The next month you will have 250.
The next month you will have 350.
The next month you will have 450.
처음 실행되는 금액 만 인출하는 것으로 보입니다. 다른 달은 그냥 100을 추가하는 것입니다. 내가 뭘 잘못하고 있니?
내 바보 같은 질문을 읽어 주셔서 감사합니다.
답변과 양해 해 주셔서 감사합니다. 나는 결코 수학에 능숙하지 못했습니다.
글쎄, 코드를 말한다 정확히 무엇을하고있어. 'balance = (income * month) - spend' – Lack
for 루프가 잘못된 것이 아니라 계산입니다. –