Streamlit magic distorts text string

When I ran this script

s = (full_name, birth_date, gender_)
'string:', s

Because streamlit got confused with the trailing underscore of gender_, it then displayed the string like this:

string: fullname, birth_date, gender

Is there a workaround to make streamlit display the string correctly, that is:

string: full_name, birth_date, gender_


Hello @jaseuts, welcome to the forum!

Streamlit magic displays your string as a markdown text, and if you wrap some markdown text between _two underscores_, it is generally displayed in italic.

You can either add a backslash before gender’s underscore…

s = "(full_name, birth_date, gender\_)"

…wrap your string with backquotes (which will render with a monospaced font)…

s = "`(full_name, birth_date, gender_)`"

…or use st.text to display your whole string (renders with a monospaced font as well):

s = "(full_name, birth_date, gender_)"
st.text("string: " + s)

@okld, thanks for your comprehensive response. Option 3 is the best!