Initializing session_state in streamlit

Help. I don’t understand why the following line is error:

# st.subheader("Total Aset Kas: {}".format(st.session_state.total_aset_kas)) #uncomment this to see the error

AttributeError: st.session_state has no attribute "total_aset_kas". Did you forget to initialize it? More info: https://docs.streamlit.io/library/advanced-features/session-state#initialization

i thought i have it initialized in initialize_totalan.

How do i resolve this?

Hi @Cignitor,

Thanks for posting!

I looked at your code and it seems you don’t have total_aset_kas in the list of session states.

Screenshot 2023-11-14 at 4.51.50 PM