# While loop workaround

**URL:** <https://discuss.streamlit.io/t/while-loop-workaround/5586>\
**Category:** Using Streamlit\
**Created:** [September 15, 2020, 5:46pm UTC](https://discuss.streamlit.io/t/while-loop-workaround/5586 "2020-09-15T17:46:30Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![randyzwitch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/randyzwitch/32/58772_2.png) [@randyzwitch](https://discuss.streamlit.io/u/randyzwitch)\
**Post date:** [September 16, 2020, 1:49pm UTC](https://discuss.streamlit.io/t/while-loop-workaround/5586/3 "2020-09-16T13:49:38Z")

</div>

For example, this terminates:

```python
import streamlit as st
import time

x = 0

p = st.empty()

while x < 10:
    p.write(f"Your value is {x}")
    time.sleep(1)
    x += 1

```

---

_[View the full topic](https://discuss.streamlit.io/t/while-loop-workaround/5586)._
