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
  ONE input => THREE outputs Tricia279 6 216 Jan-14-2021, 08:52 AM
Last Post: perfringo
  Multi set string inputs/outputs kwmcgreal 2 319 Sep-26-2020, 10:44 PM
Last Post: kwmcgreal
  How to use subprocess to get multiple data outputs in desired folder? 3SG14 1 396 Sep-19-2020, 05:46 PM
Last Post: bowlofred
  Outputs missing SamAnw 4 530 Feb-12-2020, 04:32 PM
Last Post: adetheheat
  Cleaner way to rewrite fakka 5 756 Dec-05-2019, 04:53 AM
Last Post: stullis
  How do I rewrite this .bat file code onto Python? SteampunkMaverick12 4 693 Nov-02-2019, 11:28 PM
Last Post: snippsat
  Interpreter and running a .py file give different outputs PythonNPC 5 835 Jul-21-2019, 01:07 PM
Last Post: PythonNPC
  Rewrite a function to make it work with 'bottle-pymysql' nikos 1 659 Feb-26-2019, 02:59 PM
Last Post: nikos
  My code is taking longer time to give result rajeshwin 4 999 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  piexif rewrite exif data yawstick 2 1,317 Oct-09-2018, 08:56 PM
Last Post: yawstick

Forum Jump:

User Panel Messages

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