Hello Everyone, it’s my first time with Streamlit !
So as the title suggests, I have an input which is a number input and depending on that input, I want to add the same number of inputs.
import streamlit as st
import functions as fcts
st.title("TEST")
c=1
if c==0:
n = int(st.session_state['nb_years'])
residual_value = [0]*n
residual_value[n-1] = st.number_input("Your residual_value")
c1,c2,c3,c4 = st.columns(4)
inv_cost = st.number_input("Your investment cost")
invested_capital = st.number_input("Your invested capital")
tax_rate = st.number_input("Your tax rate in percentage")
tax_rate = tax_rate/100
percentage_vc = st.number_input("Your variable cost in percentage")
percentage_vc = percentage_vc/100
with c1:
turnover=[0]*n
for i in range(n):
pos = i+1
turnover[i] = st.number_input("Your turnover for year {}".format(pos))
with c2:
fixed_cost = [0]*n
for i in range(n):
pos = i+1
fixed_cost[i] = st.number_input("Your fixed cost for year {}".format(pos))
with c3:
wcr_recovery = [0]*n
for i in range(n):
pos = i+1
wcr_recovery[i] = st.number_input("Your working capital requirement recovery for year {}".format(pos))
with c4:
wcr_variation = [0]*n
for i in range(n):
pos = i+1
wcr_variation[i] = st.number_input("Your working capital requirement variation for year {}".format(pos))
disc_rate = 0.1
npv = fcts.process(turnover,percentage_vc,fixed_cost,inv_cost,n,invested_capital,tax_rate,wcr_recovery,wcr_variation,residual_value,disc_rate)
st.write("Your npv", npv)
if 'nb_years' not in st.session_state:
n = st.number_input("nb_years")
st.session_state['nb_years'] = n
c=0
So I thought about a lot of solutions and when I finally thought i found it, it didn’t work.
As you see here, I want that nb_years to be the first input and depending on it, I want other inputs like turnonver each year …
Please Help ! Thank you in advance !