value is not added to dictionary

Viewed 26

I'm trying to get the values ​​for the dictionary through the bot, but they are not added to the dictionary. when I try to get the value it throws an key error. how do i fix this? here is my code:

class UserState(StatesGroup):
inn = State()
number = State()
   
info = {}

@dp.message_handler(commands=['start'])
async def start(message: types.Message):
    await UserState.inn.set()
    await message.answer("Введите ИНН")


@dp.message_handler(state=UserState.inn)
async def inn_register(message: types.Message, state: FSMContext):
    global a
    async with state.proxy() as info:
        info['inn'] = message.text
        a = info['inn']
        await UserState.next()
        await message.answer("Введите реквизиты")


@dp.message_handler(state=UserState.number)
async def number_register(message: types.Message, state: FSMContext):
    async with state.proxy() as info:
        info['number'] = message.text

        await message.answer(f"ИНН: {info}\n"
                             f"Реквизиты: {info['number']}")
0 Answers
Related