Skip to content
← Back to Community
how do i get it to work?
Profile icon
SethElder1

so waht im trying to do is create a code that takes user, initail investment value, intrest rate, how long the investment is active, and how long it needs to go, then it gives how much the investment is worth each month. but it isnt working, ive looked at a example that i was given of something like this and took some of its code, but it still isnt working

Voters
Profile icon
SethElder1
Comments
hotnewtop
Profile icon
Spacecraft

I helped you with a couple bugs. Variables m and l needed to be integers. Variable r was clarified to be % anually. The output function needed to use the variable t for each month to calculate properly.

def info(): i = float(input("initial investment: ")) r = float(input("intrest rate % annually: "))/100 m = int(input("how long are you investing in months?: ")) l = int(input("how long has your investment been going? ")) return(i, r, m, l) def calculate(i, r, m, l): d = i*(1 + (r/12)*m)**(l/m) return d def output(i, r, m, l): for t in range (1, l+ 1): print("month", t, "/lbalance: $", "{:.2f}".format(calculate(i, r, m, t))) a, b, c, d = info() total = calculate(a, b, c, d) print("your investment is worth $", total) output(a, b, c, d)
Profile icon
SethElder1

how do i do that? @CosmicBear

Profile icon
MrVoo

Don't say "it isn't working", tell what happened and what you wanted to happen.
You put everything in functions, but never ran the functions.

Profile icon
SethElder1

i want to know how to make it output a list of numbers, and these numbers are what number of month it is (for instance month 14) and i want it to say what the total investment is worth for that month (so month 14 is worth $1000) as for what happened when i ran the code, it said nothing, no errors occured, and it returned nothing @MrVoo

Profile icon
CosmicBear

@SethElder1 Just get the inputs and run the functions.

Profile icon
SethElder1

what happened when i ran the code was nothing, i ran the code ans it said nothing, no errors occured, it didnt return anything, other than a black screen @MrVoo

Profile icon
SethElder1

how do i get it to do that? @CosmicBear

Profile icon
SethElder1

how do i do that? @CosmicBear

Profile icon
MrVoo

@SethElder1 Run the functions, all you have are functions. functionName()

Profile icon
CosmicBear

@SethElder1 Maybe learn some python from a tutorial first. https://www.w3schools.com/python/python_functions.asp