There handlers for get message from user and that work but in for loop I need to stop loop and get new message from user and store it in variable new_answer
. Then I need use that variable in if statement
but I not get how to do that
@router.message(F.text == "Let's play!")
async def nice(message: Message, state: FSMContext, new_answer = Playgame.number ):
await state.set_state(Playgame.number)
numbers = []
user_score = 0
for i in range(1, 101, 1):
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
result = num1 + num2
if result not in numbers:
numbers.insert(0, result)
else:
pass
await message.answer(f'game started at, {i}) {num1}+{num2}=__?', reply_markup=kb.gamekeyboard)
i += 1
if int(new_answer) == result: /*user input should come here/*
user_score += 1
await message.reply("Yes right! you score: ", user_score)
else:
user_score -=1
await message.reply("No that is mistake! next question! your score: ", user_score )
@router.message(Playgame.number)
#that handler try to get number from user input
async def process_number(message: Message, state: FSMContext) -> None:
await state.update_data(number=message.text)
await message.answer(f"Your answer is '{message.text}'") /*i get Echo msg here/*
new_answer = await state.get_state()
/*that i need use that user input after i += 1 before if statement/*
/*TypeError: int() argument must be a string, a bytes-like object or a real number, not 'State'/*
/*maybe that i stack in without any solution results, that is my first question so /*
/*its to easy to solve/*
New contributor
JohnyBi python beginner is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.