Hi! I’m trying to have page elements in an iterable display element by element until a user is done. I’ve implemented this with a recursive function, that I’ve simplified here:
def write_i(i): st.write(i) if i == 5: return if st.button('Next?', key=i): i += 1 write_i(i)
If I call
write_I(0), I’d expect 0 to print and the button ‘Next?’ to appear then, on clicking, for 1 to appear and the button, and so on until 5 is printed.
It seems to work for the first two iterations: I see
0, Next? then '1, Next?` – but on clicking that ‘Next’ button, the page starts again at 0.
Am I missing something? Thanks!