Create a user defined number of loops for quiz in python
<p>I need to have a user defined amount of time the questions are asked and keep track of the attempts</p>

<pre><code>def main(): 
    print("Thank you for taking the Quiz")

    score= 0
    question1 = input("How many donuts are in a dozen? ")
    if question1 == "12":
        print("Correct")
        score = score +1
    else:
        print("Incorrect")

    question2 = input("How many mb are in a gb? ")
    if question2 == "1024":
        print("Correct")
        score = score +1
    else:
        print("Incorrect")

    question3 = input("How many pokemon are in gen 1? ")
    if question3 == "151":
        print("Correct")
        score = score +1
    else:
        print("Incorrect")




    print("The final score is: " + str(score), "out of 3")

main()    
</code></pre>

<p>I would do something like this:</p>

<pre><code>    def main(): 
        print("Thank you for taking the Quiz")

        times = input("How many time you'll play? ")

        for i in range(int(times))
            print("The final score is: " + str(question), "out of 3")

def question():
        score= 0
        question1 = input("How many donuts are in a dozen? ")
        if question1 == "12":
            print("Correct")
            score = score +1
        else:
            print("Incorrect")

        question2 = input("How many mb are in a gb? ")
        if question2 == "1024":
            print("Correct")
            score = score +1
        else:
            print("Incorrect")

        question3 = input("How many pokemon are in gen 1? ")
        if question3 == "151":
            print("Correct")
            score = score +1
        else:
            print("Incorrect")

        return score

    main() 
</code></pre>

python python-3.x