2013-10-02 24 views
0

我對python和編程總體非常陌生,並且我的作業任務是在python 2.7 pyscripter上編寫程序。一旦我寫了程序,我打了跑,它問我的用戶輸入。之後沒有任何事情發生,它說調試正在進行中。我等了,但沒有發生任何事。 繼承人的代碼:python程序未開始調試

in_balance = float(raw_input("Enter the outstanding balance on your credit card")) 
int_rate = float(raw_input('Annual interest rate as decimal')) 
min_month_pay = 0 
month_int_rate = int_rate/12 
month = 0 
balance = in_balance 

while balance > 0: 
    month = 0 
    balance = in_balance 
    min_month_pay = min_month_pay + 10 
    while month < 12 and balance > 0: 
     month = month + 1 
     interest = month_int_rate * balance 
     balance = balance + interest 
balance = round(balance, 2) 
print 'result' 
print 'month pay to pay off in 1 year: $', min_month_pay 
print 'number of months needed: ', month 
print 'Balance: $', balance 
+0

您的外部'while'循環在每次迭代中將'balance'重置爲'in_balance'。所以它似乎永遠不會退出該循環。我沒有看到任何會將'balance'減少到零以退出循環的東西。你忘了付餘額嗎? – bogatron

+0

ohh,所以它會說調試,如果它卡在無限循環? – snukumas

回答

0

正如bogatron說,你有一個無限循環,只要in_balance> 0,我不熟悉pyscripter,但如果它像任何其他調試器,它會說「調試「如果它正在執行任何代碼。如果你暫停了t,你會看到它停在while循環的其中一行。不確定嘗試的功能是什麼,但我不確定爲什麼你有while循環開始,因爲即使每次都沒有重新分配,平衡也不會減少。