title: how to pass a filename as function parameter in python?
body: <p>I've got a problem to solve that says <strong>. Write a function in python that will take a file name fname and a string s as input. It will return whether s occurs inside the file. It's possible that the file is extremely large so it cannot be read into memory in one shot</strong>
  and I've done a solution for that like this</p>
  <pre><code>import fileinput
  def FileAndString(s,filename):
      
      inname =input(filename)
      s =s
      fname= open(fileinput.input(files ='inname'))
      flag = 0
      index = 0
      for line in fname:
          index += 1
          if s in line:
              flag = 1
              break
      if flag == 0:
          print(&quot;string&quot;, s, &quot;not found&quot;)
      else:
          print('String', s, 'Found In Line', index)
  FileAndString('goal','fname.txt')
  </code></pre>
  <p>and I'm getting an error like this</p>
  <pre><code>  traceback (most recent call last):
    File &quot;c:/Users/hp/Desktop/test/repo/file.py&quot;, line 19, in &lt;module&gt;
    File &quot;c:/Users/hp/Desktop/test/repo/file.py&quot;, line 10, in FileAndString
      index += 1
    File &quot;C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\fileinput.py&quot;, line 248, in __next__
      line = self._readline()
    File &quot;C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\fileinput.py&quot;, line 366, in _readline
      self._file = open(self._filename, self._mode)
  FileNotFoundError: [Errno 2] No such file or directory: 'inname'
  </code></pre>
  <p>and my question is:
  is this the right way to do it?
  how to pass that fname.txt or any file as a parameter</p>