money = float(input("please input you want to double the money:"))
double_money = money * 2
year = 0
interest = float(input("please input interest:"))
interest_money = 0
while money <= double_money:
    interest_money = money * interest
    money += interest_money
    year += 1
    print(f"generate interest {interest_money} in year {year}")
print(f"your money need {year} year to double it...")

更多推荐

用python计算你的钱放在银行里多少年才能翻倍