title: Searching keywords in a text file with a dictionary with python
body: <p>I am trying to search a lot of keywords in a textfile and return integers/floats that come after the keyword. 
  I think it's possible using a dictionary where the keys are the keywords that are in the text file and the values are functions that return the following value.</p>
  
  <pre><code>import re
  
  def store_text():
      with open("path_to_file.txt", 'r') as f:
          text = f.readlines()
          return text
  
  abc = store_text()
  
  def search():
          for index, line in enumerate(abc):
              if "His age is:" in line:
                  return int(re.search(r"\d+", line).group())
  
  
  dictionary = {
      "His age is:": print(search())
  }
  
  </code></pre>
  
  <p>The code returns the value I search in the text file but in search() I want to get rid of typing the keyword again, because its already in the dictionary.
  Later on I want to store the values found in an excel file.</p>