Open bbelderbos opened 8 months ago
Actually I misstated .get()
in a previous comment, that is to only retrieve values, to remove the bunch of if statements in the related comment you can do something like this:
st.session_state.setdefault("api_search_results_name", "")
st.session_state.setdefault("api_search_results_nutrients", [])
st.session_state.setdefault("cached_ingredient_names_and_nutrients", {})
st.session_state.setdefault("nutrients_i_need", recommended_daily_nutrients)
st.session_state.setdefault("nutrients_i_have", recommended_daily_nutrients_empty)
See: https://www.w3schools.com/python/ref_dictionary_setdefault.asp
@anschelburk another easy one to quickly add today if you can ...
_Originally posted by @bbelderbos in https://github.com/anschelburk/PDM-Nutrient_Guide/pull/44#discussion_r1519613438_