Spaces:
Runtime error
Runtime error
import streamlit as st | |
import random | |
# Display a title and instructions | |
st.title('Random Number Generator') | |
st.write('Click the button to generate a new random number.') | |
# When the button is clicked, Streamlit reruns the script from the top. | |
# Thus, we generate a new random number on each run. | |
if st.button('Refresh Number'): | |
random_number = random.randint(1, 100) | |
# Display the random number in the app. | |
st.write(f'Random Number: {random_number}') | |
else: | |
# Initial message before button is pressed for the first time. | |
st.write('Press the button to generate a random number.') | |