Multiple buttons, DuplicateWidgetID

Hello, my problem is if I add a key to the buttons, the “DuplicateWidgetID” Error disappears, but the informations doesnt refresh, like I want them too. If I do it without key, it works at least once, but when I click a button the second time, the whole site refreshes. I want only the informations to refresh, every time I click a button.

def showAdditionalInformations(symbol22):
    apiURL = f'{symbol22}/company?&apiKey={apiKey}'
    response = requests.get(apiURL)
    additionalData = response.json()
    country.write("County: " + additionalData['country'].upper())
    industry.write("Industry: " + additionalData['industry'])
    sector.write("Sector: " + additionalData['sector'])
    marketcap.write("Maketcap: $" + str( additionalData['marketcap'] ))
    ceo.write("CEO: " + additionalData['ceo'])
    employees.write("Employees: " + str(additionalData['employees']))

    corrHeader.header("Correlate with similar stocks:")
    result = []
    count = 0
    for i in additionalData['similar']:
        key = i+"_"+str(random.randint(1,9999))
        a = corrButton[count].button(i, key)
        result.append( a )

        if result[count]:
            stock_symbol.text_input("Stock Symbol", i)
    st.write("Similar stocks: " + str(additionalData['similar']))

Try using check boxes rather than buttons as buttons will cause a refresh on the next interaction.

This depends a little on what you’re actually trying to do with the app.

It’s also helpful to link to the remainder of your code if possible.