Python Forum
how do i rewrite this code to give me 10 outputs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do i rewrite this code to give me 10 outputs
#1
# File: Futurevalue.py
# A simple program illustrating the future value of a savings account in 10 years
def main():
    p = eval(input ("Enter the initial principal amount in the savings account: "))
    apr = eval(input ("Enter the annual interest rate: " ))
    for i in range(10):
        p = p*(1 + apr)
                                 
    print("The value in 10 years is:", p)
    


main()
Reply
#2
your print statement is outside the loop.
Add 4 spaces before the print, thus making it part of the loop and you will see 10 outputs
Reply
#3
(Mar-29-2018, 04:24 AM)Larz60+ Wrote: your print statement is outside the loop.
Add 4 spaces before the print, thus making it part of the loop and you will see 10 outputs

That works. Thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Combining outputs into a dataframe rybina 0 141 Mar-15-2021, 02:43 PM
Last Post: rybina
  ONE input => THREE outputs Tricia279 6 352 Jan-14-2021, 08:52 AM
Last Post: perfringo
  Multi set string inputs/outputs kwmcgreal 2 404 Sep-26-2020, 10:44 PM
Last Post: kwmcgreal
  How to use subprocess to get multiple data outputs in desired folder? 3SG14 1 489 Sep-19-2020, 05:46 PM
Last Post: bowlofred
  Outputs missing SamAnw 4 634 Feb-12-2020, 04:32 PM
Last Post: adetheheat
  Cleaner way to rewrite fakka 5 902 Dec-05-2019, 04:53 AM
Last Post: stullis
  How do I rewrite this .bat file code onto Python? SteampunkMaverick12 4 833 Nov-02-2019, 11:28 PM
Last Post: snippsat
  Interpreter and running a .py file give different outputs PythonNPC 5 919 Jul-21-2019, 01:07 PM
Last Post: PythonNPC
  Rewrite a function to make it work with 'bottle-pymysql' nikos 1 719 Feb-26-2019, 02:59 PM
Last Post: nikos
  My code is taking longer time to give result rajeshwin 4 1,129 Feb-20-2019, 08:18 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020