Def name():

Hi I notice that streamlit coding might be a bit different from python. I am new to streamlit. May I know for function def name(): do I have to code return ? Python needs to but I feel that streamlit dont need. Please advice if my understanding is correct. Example in python if I want to get x, my def name(): must have a return x.

def name():
x = 1+1
return x

name()

Hi @AliceKoh,

Thanks for posting!

If you don’t include a return statement in your Python function, the function will automatically return None. The same will happen with functions in Python files that also use Streamlit.

Caroline :balloon:

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