Как можно сделать переменную balance глобальной?
#
mycursor.execute(f"SELECT user_id, balance from user_tg WHERE user_id like '{callback.message.from_user.id}'")
result = mycursor.fetchall()
for x in result:
balance = ("%d" % (x[1]))
btn_menu_profil = InlineKeyboardMarkup(row_width=1)
back = InlineKeyboardButton(text="Назад", callback_data="back")
pay = InlineKeyboardButton(text="Пополнить баланс", callback_data="pay")
btn_menu_profil.add(pay, back)
lk_text = f"""<b>Личный кабинет:
— — — — — — — — — —
ID: {callback.message.from_user.id}
Баланс: {balance}₽
Ошибка
local variable "balance" might be referenced before assignment