title: Python, selecting a specific file
body: <p>I need to select a specific file, after specifying the number of this file in &quot;if&quot;...</p>
  <p>Instead of &quot;MTS.txt &quot; we need the full path to the selected file using a digit!</p>
  <p>I have not found any information about this on the Internet. Perhaps he made up his request badly!</p>
  <pre><code>from email import message
  from click import clear
  
  import pywhatkit
  import pyfiglet
  import os
  import time
  
  directory = 'MTS/'
  # files = os.listdir(directory)
  
  f = True
  while (f==True): 
      def main():
          os.system('CLS')
  
          # print(files)
  
          mtstxt = pyfiglet.figlet_format(&quot;Wa Helper&quot;, font = &quot;smslant&quot;)
          print(mtstxt)
          def send_message_inst():
              mobile = '+7' + input(' Номер: +7')
  
              with os.scandir(directory) as files:
                  for i, file in enumerate(files):
                      print('   ', i + 1, file.name)
              nof = os.listdir(path=&quot;MTS/&quot;)
              # print(len(nof))
              
              while True:
  
                  tarif = int(input(' Вариант: '))
                  if tarif &gt;= 1 and tarif &lt;= int(len(nof)):
                      msg = open(&quot;MTS.txt&quot;, encoding='UTF-8')
                      message = msg.read()
                      msg.close()
                      break
  
                  else:
                      os.system('CLS')
                      print(mtstxt)
                      print(' Номер:', mobile)
                      with os.scandir(directory) as files:
                          for i, file in enumerate(files):
                              print('   ', i + 1, file.name)
                      print(&quot;\033[31m{}\033[0m&quot;.format(&quot; Ошибка - неверный вариант!&quot;))
                  
              pywhatkit.sendwhatmsg_instantly(phone_no=mobile, message=message)
          
  
          send_message_inst()
          os.system('CLS')
          sndtxt = pyfiglet.figlet_format(&quot;Sent!&quot;, font = &quot;smslant&quot;)
          print(sndtxt)
          time.sleep(5)
      
      
      if __name__ == '__main__':    
          main()
      else:
          break
  </code></pre>