I need to figure out how to make my program repeat. (Python coding class)
Question: I am a beginner student in a python coding class. I have the majority of the
done and the program itself works, however I need to figure out a way to make
the program ask if wants a subtraction or an adding problem, and if the user
would like another question. I asked my teacher for assistance and he hasn't
gotten back to me, so I'm simply trying to figure out and understand what
exactly I need to do.

    
    
    import random
    
    x = int(input("Please enter an integer: ")) 
     if x < 0:
    
        x = 0
    
        print('Negative changed to zero')
    
     elif x == 0:
    
        print('Zero')
    
     elif x == 1:
    
         print('Single')
    
     else:
    
         print('More')    
    
     maximum = 10 ** x;
     maximum += 1
     firstnum = random.randrange(1,maximum)       # return an int from 1 to 100
    
     secondnum = random.randrange(1, maximum)
    
     compsum = firstnum + secondnum           # adds the 2 random numbers together
    
    #  print (compsum)                       # print for troubleshooting
    
     print("What is the sum of", firstnum, " +", secondnum, "?")    # presents problem to user
    
     added = int(input("Your answer is: "))   # gets user input
    
     if added == compsum:                     # compares user input to real answer
    
       print("You are correct!!!")
    
     else:
    
       print ("Sorry, you are incorrect") 
    


Answer: You'll want to do something like this:

    
    
    def foo():
        print("Doing good work...")
    
    while True:
        foo()
        if input("Want to do more good work? [y/n] ").strip().lower() == 'n':
            break
    

I've seen this construct (i.e., using a `break`) used more often than using a
[sentinel](https://en.wikipedia.org/wiki/Sentinel_value) in Python, but either
will work. The sentinel version looks like this:

    
    
    do_good_work = True
    
    while do_good_work:
        foo()
        do_good_work = input("Want to do more good work? [y/n] ").strip().lower() != 'n'
    

You'll want to do more error checking than me in your code, too.

