App concept: Asking for help with a bit of direction

Hi all,
I am developing a concept for an app in my head and I was hoping for a bit of advice on how to approach this. I have used Streamlit for 6 months, mostly for dynamic plotting of data, so I know the basics.

The concept is this:

a) I will have a number of photos stored somewhere (like github). Each photo contains a number of items (cats, dogs, etc).

b) The user opens the streamlit app and a random image is shown. The user is asked how many cats are in this image and they can input this value.

c) Part b) repeats 10 times (i.e. a different image loads with a different number of cats), until there is 10 user inputs.

d) After 10 user inputs, the app calculates the users score and displays results.

I know I can create a place for my images using st.empty() and update the image after each input. That seems like it should be OK.
The thing I am a little confused about is how I can collate the user inputs, since every time the user enters their answer, wont the app reset?

Maybe it is easier than I am thinking, but any advice or help, or things I have not thought of yet, would all be appreciated.

Thank you for taking the time to read :slight_smile:

Hey @LukeF,

Don’t know how much time you have been spending on the forum in the last few months but I think the easiest way to do this is using session state.

You can easily store each of the user’s answers in st.session_state, and then compare them with the “correct” values once they are finished! here are some links for you to get started:

Happy Streamlit-ing!
Marisa

1 Like

Thank you. I have not tried session state, but this seems like a good excuse to learn!

Thanks again!

1 Like