title: Can't figure out how to get a flag loop working properly. Keep getting syntax errors.
body: <p>I need to write a program that will create random math problems. </p>
  
  <p>Each problem should have the following format:</p>
  
  <pre><code>    &lt;num&gt; &lt;op&gt; &lt;num&gt;  = ?
  </code></pre>
  
  <p>Where each num represents a random number between -50 and 50 and op is randomly selected from the four basic math operators: +, -, /, *.</p>
  
  <p>The program will present this problem to the user and wait for an answer.  If the answer is correct the program should congratulate the user and exit.  If the answer is not correct the program should allow the user to try again.  The user will be allowed to keep trying until the correct answer is given. </p>
  
  <p>Every time the code is compiled, I get an error at "flag" for syntax but I don't know how to fix it.</p>
  
  <pre><code>    def main(): 
  
          import random
          from operator import add, sub, mul, div
  
          random.seed()
  
          ops = (add, sub, mul, div)
          op = random.choice(ops)
  
          num1 = random.randint(-50,50)
          num2 = random.randint(-50,50)    
  
          answer = op(num1, num2)
  
          print("Welcome! Here is your practice problem:\n")
  
          print(num1, op ,num2,"=?\n")
  
          guess = int(input("What is your answer?\n")
  
          flag = True
  
          while flag:
              guess = int(input("I’m sorry, that is not correct.  Please try again.\n"))
  
              if guess == answer:
                  flag = False
          print("Congratulations! You have answered the problems correctly!\n)
  
  
      main()
  </code></pre>