title: Python program to calculate the years to double investment
body: <p>Here is the program I've written to calculate the number of years it would take to double an initial investment, but it isn't working...</p>
  
  <pre><code>def main():
  
      x = eval(input("Enter initial investment: "))
      a = eval(input("Enter the annual interest rate: "))
      f = x * (1 + a)
  
      while f == 2 * x:
          t = x * 2 / x * (1 + a)
          print("The initial investment will double in",t)
  
  main()
  </code></pre>
  
  <p>The program asks for the interest rate and principal, but then it stops. I have to use a while loop. Thanks in advance for your help!</p>