title: Can't make my code identify specific strings
body: <p>I'm coding for a little school project. I wanna read a .txt file and find what's between "pergunta[]" and a question mark but can't manage to make my program give me that.</p>
  
  <p>I have already tried what someone suggested <a href="https://stackoverflow.com/questions/55188056/how-to-extract-text-between-the-matching-pattern-in-python?noredirect=1&amp;lq=1">here</a> but it doesn't seem to work for me, as it does not retrieve the piece of string I want and apparently does not even enter the if statement.</p>
  
  <p>("perguntas" means questions)</p>
  
  <pre class="lang-py prettyprint-override"><code>import pyttsx3
  
  speak = pyttsx3.init()
  
  running = True
  perguntas = open(r"C:\Users\jeana\Desktop\perguntas.txt", "r")
  texto = perguntas.read()
  
  while running:
      if "pergunta5 " in texto:
          data = texto.split("pergunta5 ")[1].split("?")[0]
          print(data) #tried adding this line but it is never printed
          speak.say(data)
          speak.runAndWait()
          running = False
      print("um loop") #I added this just to know the code reaches this point
      running = False
  </code></pre>
  
  <p>I expected my code to find the question that is between "pergunta[]"(5 in this case, just to simplify) and "?" and text-to-speech it, but for some reason this code simply outputs something that sounds like a "p" and no error messages. I wonder if I'm missing something that is fundamental here...</p>
  
  <p>The text file looks like this:</p>
  
  <pre><code>pergunta1 Quanto é dois mais dois? R: 4 - 2
  pergunta2 Quanto é cinco menos 2? R: 3 - 2
  pergunta3 Quanto é cinco menos 1? R: 4 - 2
  pergunta4 A peppa pig é um? R: Porco - 3
  pergunta5 Qual a cor do cavalo branco do napoleão? R: Branco - 3
  </code></pre>
  
  <p>edit:
  A simpler version of my code is </p>
  
  <pre class="lang-py prettyprint-override"><code>text = "a lot of text with some question1 yadayadayada? question2 dayadayadaya?"
  if "question1" in text:
      data = text.split("question1")[1].split("?")[0]
      print(data)
  </code></pre>
  
  <p>and the output should go:</p>
  
  <pre><code>yadayadayada
  </code></pre>