0

Hi All

I'm new to Python and have created the below little program but would like to be able to print the loop final count (eg. 8 years) rather than every loop. Any hints on how to do this?

def main():

print "This program calculates how long it takes for an investment to double in size."

investment = 1000 #initial investment

rate = input("Please enter the applicable interest rate: ") #interest rate input

years = 0 #sets years to zero

value = investment

while value <= investment*2: #defines loop sentinel

value = value +value*((float(rate)/100)) #calculates investment

years = years + 1 #adds a year for every loop

print "The investment doubles in",years,"years" #prints the years it took to double the investment

main()