def main():
account_value = input("Enter your account value: ")
AV = account_value
years = input("Enter how many years you want to save: ")
IR = input("enter the interest rate per year: ")
for i in range(int(years)):
aftervalue = int(AV) + (float(IR)*int(AV))
print(aftervalue)
爲什麼我必須將它們轉換爲循環中的表達式?爲什麼我必須轉換變量?
爲什麼他們已經被視爲整數和浮點數?
在Python 3中,'input()'返回一個字符串,它不解析輸入。 – Barmar
爲什麼在一個循環中爲同一個變量賦值相同的變量?每次都是一樣的。 – Barmar
不要將它們轉換成循環,在分配變量時將它們轉換一次,例如'年= int(輸入(「輸入年份:」))' – Barmar