# Question about magic command

**URL:** <https://discuss.streamlit.io/t/question-about-magic-command/29836>\
**Category:** Using Streamlit\
**Created:** [August 26, 2022, 1:49am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836 "2022-08-26T01:49:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![players\_hub](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/players_hub/32/18034_2.png) [@players\_hub](https://discuss.streamlit.io/u/players_hub)\
**Post date:** [August 26, 2022, 1:49am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836/1 "2022-08-26T01:49:40Z")

</div>

Hi,

I am still a newbie dev, My question is there a way to remove the default output of streamlit?  
what I mean is I use st.input command and every time I run it, streamlit provides a default value as the output even though i haven’t put anything as input I tried to configure it and change the magic to false in the configuration setting of streamlit but still the same.

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [August 26, 2022, 2:46am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836/2 "2022-08-26T02:46:04Z")

</div>

Hi @players_hub  
Could you share your code snippet or a link to your GitHub repo.

---

<div class="post-metadata">

**Author:** ![players\_hub](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/players_hub/32/18034_2.png) [@players\_hub](https://discuss.streamlit.io/u/players_hub)\
**Post date:** [August 26, 2022, 3:30am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836/3 "2022-08-26T03:30:37Z")

</div>

I created basic code to show what I am asking

code:  
import streamlit as st

first\_val = st.number\_input(“Enter number:”)  
second\_val = st.number\_input(“Enter second number”)  
add\_val = first\_val + second\_val  
st.write(add\_val)

output

 ![result](https://global.discourse-cdn.com/streamlit/original/3X/d/1/d1a5bfc2e1481eb0c841ab69c1e1a94cc70b065e.jpeg)

if your going to check the image above, I put 3 as an input then streamlit show it right away . What I want to happen is streamlit show an output after calculation. I guess it got something to do with the magic command? i try to turn it off but its still the same so I dont have an dea

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [September 7, 2022, 1:34am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836/4 "2022-09-07T01:34:00Z")

</div>

Hi,

You can embed your code inside `st.form` then use conditionals to display the sum value after the submit button is clicked.

Here’s a revised version of this:

```auto
with st.form('my_form'):
  first_value = st.number_input('Enter number:')
  second_value = st.number_input('Enter second number:')

  submitted = st.form_submit_button('Submit')
  if submitted:
      add_value = first_value + second_value
      #st.write(add_value)

if submitted:
  st.write(add_value)

```

Now, the output will only be shown after the submit button is clicked.

I’ve created a GitHub repo here [st-form-example/streamlit\_app.py at master · dataprofessor/st-form-example · GitHub](https://github.com/dataprofessor/st-form-example/blob/master/streamlit_app.py)

And a demo app of this here [https://dataprofessor-st-form-example-streamlit-app-rz5jl9.streamlitapp.com/](https://dataprofessor-st-form-example-streamlit-app-rz5jl9.streamlitapp.com/)

Hope this helps 😊

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [September 7, 2023, 1:34am UTC](https://discuss.streamlit.io/t/question-about-magic-command/29836/5 "2023-09-07T01:34:48Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
