Cannot delete None at the bottom

I try to prepare a questionnaire of 5 yes no questions.

The problem is after the result line at the end there are 5 lines only written as None.

The code is :slight_smile:

answers = [β€˜Yes’, β€˜No’]

question_1 =β€˜1.tired.’, answers)

tip_1.append(1) if question_1 == β€˜Yes’ else tip_1.append(0)

question_2 =β€˜2.dizzy.’, answers)

tip_5.append(1) if question_2 == β€˜Yes’ else tip_5.append(0)

question_3 =β€˜3.Nausea.’, answers)

tip_9.append(1) if question_3 == β€˜Yes’ else tip_9.append(0)

question_4 =β€˜4.Vomit.’, answers)

tip_2.append(1) if question_4 == β€˜Yes’ else tip_2.append(0)

question_5 =β€˜5.Headache.’, answers)

tip_8.append(1) if question_5 == β€˜Yes’ else tip_8.append(0)

sum_lists = [sum(tip_1), sum(tip_2), sum(tip_3), sum(tip_4), sum(tip_5), sum(tip_6), sum(tip_7), sum(tip_8), sum(tip_9)]

max_list_index = sum_lists.index(max(sum_lists))

tab_2.write(f"Your type is tip{max_list_index + 1}")

In the website, after the result line there are 5 lines of None





I couldn’t get rid of them.

I have three tabs and I have these five None line in each of the tabs.

Could you please help me?

Try turning off Streamlit Magic. Or terminate the if/else constructs with a semi-colon.

1 Like

Hi @Yusuf_Gungoray

Agreeing with @asehmi that the if/else formatting may be the cause of the problem:

Try refactoring the code in the following structure:

if question_1 == β€˜Yes’:

Thank you so much. It worked

Thank you so much for the code. It was very helpful.

1 Like

Glad to hear that it works now.