title: ask user enter a file to run the program with python
body: <p>I have a program that concatenates French words separated by an asterisk in a text. As I want this program to be used by different users, I want to insert a line in the program asking the user to enter the path of the text file or simply enter the name of the text…How to do that? Just using function “input”? I have no idea…Is there an elegant way to ask that to the user to run the program? The program is below:</p>
  
  <pre><code>import nltk
  from nltk.tokenize import word_tokenize
  import re
  
  
  
  with open ('text-test.txt') as tx:
     words = word_tokenize(tx.read().lower())
  
  with open ('Fr-dictionary.txt') as fr:
      dic = word_tokenize(fr.read().lower())
  
  l=[ ]
  errors=[ ]
  out_file=open("newtext.txt","w")
  
  for n,word in enumerate (words):
      l.append(word)
      if word == "*":
          exp = words[n-1] + words[n+1]
          print("\nconcatenation error:", exp)
  
          if exp in dic:
  
              l.append(exp)
              l.append("$")
  
              errors.append(words[n-1])
  
              errors.append(words[n+1])
          else:
             continue
  
  for i, w in enumerate(l):
      if w == "*":
          l.remove(l[i-1])
      else:
          continue
  
  for i, w in enumerate(l):
      if w == "$":
          l.remove(l[i+1])
      else:
          continue
  
  
  text=' '.join(l)
  print('\n\n',text)
  e=len(errors)
  
  print('\n',e/2,'WORDS CONCATENATED IN TEXT',errors)
  
  
  user=input('\nREMOVE * AND $ FROM TEXT? Type "Y" for yes or "N" for 
  no:')
  
  
  for x in l:
      if user=='Y' and x=='*':
          l.remove(x)
      elif user=='Y' and x=='$':
          l.remove(x)
      else:
          continue
  
  
  final_text=' '.join(l)
  
  print('\n\n', final_text)
  
  
  user2=input('\nWrite text to a file? Type "Y" for yes or "N" for no:')
  
  if user2 =='Y':
      out_file.write(final_text)
      out_file.close()
      print('\nText named "newtext.txt" written to a file')
  </code></pre>