Summary
I have a snippet of code that takes input from the user and adds single quotes and comma’s around each entry.
Steps to reproduce
Code snippet:
def format(user_text):
return ", ".join(repr(s) for s in user_text.replace(',', "").split())
user_text = st.text_area('txt')
st.code(format(user_text))
What I would like to do is create a new like after 80 characters or so (if that line isn’t a comma).
I’ve tried this but it’s printing out twice and I’m not sure why.
updated_text = ", ".join(
repr(s) for s in user_text.replace(',', "").split())
for i, letter in enumerate(updated_text):
if i % 80 == 0 and i != ',':
updated_text += '\n'
updated_text += letter
return updated_text