0

First question, so please be nice...also the first program I've ever built from the ground up.

Really basic quiz program. There are three possible answers. If the input is out of range, the program returns an error message.

But, I'd like to give the user another shot at it if the user puts something in that's completely out of range. Right now the program just keeps progressing and won't repeat the last question.

Additionally, testing for a letter instead of an integer is not working.

Thanks for any help passed onto this first timer.

for i in range(1, len(questions)):
    print""
    print""
    print "Number " + str(i) + ":  " + questions[i]
    print ""
    answers = raw_input("Select 1 for Demolition Man\n2 for Judge Dredd\nor 3 for BOTH!\nAnswer ")
    if answers == answer_key[i]:
        score += 1
        print "Correct!"
    else:
        if answers < 1:
            print "Sorry, that's not one of the possible answers"
            i -= 1
        elif answers > 3:
            print "Sorry, that's not one of the possible answers"
            i -= 1
        elif type(answers) != int:
            print "Sorry that's not one of the possible answers"
            i -= 1
        else:
            print "You just don't know that one..."
Patrick
  • 65
  • 5
  • Is this for a class? If so just add some context (like I cannot use comprehensions, generators, or try/except) so the answers given will be more useful to you. For your second question see: [How do I check if a string is a number](http://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float-in-python) and check out [while loops](https://wiki.python.org/moin/WhileLoop) for the first – LinkBerest Apr 11 '16 at 03:09
  • No, I'm learning programming, and as I learn, I've been given the advice to program instead of just taking classes...so this is all independent....thanks! – Patrick Apr 11 '16 at 03:26

0 Answers0