title: Is it possible to save the print-output in a dict with python?
body: <p>I want to know, if it's possible to save the output of this code into a dictionary (maybe it's also the wrong data-type). I'm not expirienced in coding yet, so I can't think of a way it could work.
  I want to create a dicitionary that has the lines of the txt.-file in it alongside the value of the corresponding line. In the end, I want to create a code, where the user has the option to search for a word in the line through an input - the output should return the corresponding line. Has anyone a suggestion? Thanks in advance! Cheers!</p>
  
  <pre><code>filepath = 'myfile.txt'  
  with open(filepath) as fp:  
     line = fp.readline()
     cnt = 1
     while line:
         print("Line {}: {}".format(cnt, line.strip()))
         line = fp.readline()
         cnt += 1
  </code></pre>