title: I can’t write an algorithm to the side that guesses numbers using the aiogram module
body: <p>I need to write a telegram bot using a module that will guess numbers, but when writing the bot itself, I came across a problem. I can’t interpret the algorithm I wrote for the aiogram module, or rather, I can’t make the second input of the number in the 'while' itself, because after I enter the number I endlessly output the result of only one 'if'. The algorithm that I tried to interpret below.</p>
  
  <pre><code>import random
  win = False
  randnum = random.randint(1,100)
  tr = 0
  print(randnum)
  while win != True:
      try:
          number = int(input())
          if number &gt; 100 or number &lt; 1:
              print('Please enter a number between 1 and 100')
              tr += 1
          elif  number &lt; randnum:
              print('This number is less than the guessed, please try again.')
              tr += 1
          elif number &gt; randnum:
              print('This number is greater than the guessed, please try again.')
              tr += 1
          elif number == randnum:
              print(f'Congratulations, you guessed right. You spent {tr} attempts on this')
              win = True
              tr = 0
      except:
          print('This is not a number. Try again')
          tr += 1
  
  </code></pre>
  
  <p>Maybe someone also faced this problem and knows how to solve it?</p>
  
  <pre><code>@dp.message_handler(lambda message: message.text == "Играть")
  async def game(message: types.Message):
      await message.reply('Number guesses')
      win = False
      number = random.randint(1, 100)
      tr = 0
      print(number)
      while win != True:
          try:
              @dp.message_handler()
              async def game(message: types.Message):
                  if int(message.text) &gt; 100 or int(message.text) &lt; 1:
                      await message.reply('Please enter a number between 1 and 100.')
                      tr += 1
                  elif int(message.text) &lt; number:
                      await message.reply('This number is less than the guessed, please try again.')
                      tr += 1
                  elif int(message.text) &gt; number:
                      await message.reply('This number is greater than the guessed, please try again.')
                      tr += 1
                  elif int(message.text) == number:
                      await message.reply(f'Congratulations, you guessed right. You spent {tr} attempts on this')
                      win = True
                      tr = 0
          except:
              await message.reply('This is not a number. Try again')
              tr += 1
  </code></pre>