'How to not make the randint to not repeat a question that was already shown before?

How to not make the randint to not repeat a question that was already shown before. after finishing the range of 10 in randint how can i add an option where the program will ask the user if it desire to choose another level. after i tried doing it in else. even if only 2 questions have asked so far. it always ended the quiz immedietely. what did i missed out with this code. help me please

import random
import string

def name():
    allowed_alpha = string.ascii_letters + string.whitespace + string.digits
    while True:
        Name = input("What is your name? ")
        if all(c in allowed_alpha for c in Name):
            grade()
        else:
            print("invalid character")
            name()

def grade():
    allowed_alpha = string.ascii_letters + string.whitespace + string.digits
    while True:
        grade.var = input("What is your grade level? (Grade 8, Grade 9, Grade 10) ")
        if all(c in allowed_alpha for c in grade.var):
            diff()
        else:
            print("invalid character")

def diff():
    Difficulty = input("\nWhat is your chosen difficulty level? (Easy, Medium, Hard) ")
    if grade.var == ("Grade 8"):
        correct = 0
        if Difficulty == ("Easy"):
            Difficulty = 1
            QN = 10
            for question in range (QN):
                Question1 = 1
                Question2 = 2
                Question3 = 3
                Question4 = 4
                Question5 = 5
                Question6 = 6
                Question7 = 7
                Question8 = 8
                Question9 = 9
                Question10 = 10
                QN = random.randint(1, 10)
                if QN == 1:
                    QA = input("\nThis is a part of speech that shows the relationship of a noun or pronoun to another word. They can indicate time, place, or relationship. \n(noun, adjective, pronoun, preposition)\n")
                    if QA == "preposition":
                        print("Correct")
                        correct = correct + Difficulty
                    else:
                        print("incorrect")
                        correct = correct - Difficulty
                        print("Your current score is " +str(correct))
                    input("\npress enter to continue")

                if QN == 2:
                    QA = input("\nWhich word indicates correct spelling? \n(belive beleive, believe, bilieve)\n")
                    if QA == "believe":
                        print("Correct")
                        correct = correct + Difficulty
                    else:
                        print("incorrect")
                        correct = correct - Difficulty
                        print("Your current score is " +str(correct))
                    input("\npress enter to continue")

                if QN == 3:
                    QA = input("\nthis figure of speech pertains to the use of 'as' and 'like' in comparing. \n(metaphor, personification, simile, hyperbole)\n")
                    if QA == "simile":
                        print("Correct")
                        correct = correct + Difficulty
                    else:
                        print("incorrect")
                        correct = correct - Difficulty
                        print("Your current score is " +str(correct))
                input("\npress enter to continue")

                if QN == 4:
                    QA = input("\nThe part of a sentence or clause containing a verb and stating something about the subject \n(subject, phrase, clause, predicate)\n")
                    if QA == "predicate":
                        print("Correct")
                        correct = correct + Difficulty
                    else:
                        print("incorrect")
                        correct = correct - Difficulty
                        print("Your current score is " +str(correct))
                    input("\npress enter to continue to the next question")

                if QN == 5:
                    QA = input("\na figure of speech that expresses exageration \n(simile, hyperbole, metaphor, personification)")
                    if QA == "hyperbole":
                         print("Correct")
                         correct = correct + Difficulty
                    else:
                        print("incorrect")
                        correct = correct - Difficulty
                        print("Your current score is " +str(correct))
                    input("\npress enter to continue to the next question")
                else:
                    next = input("Do you want to proceed to another level? (yes, no) ")
                    if next == "yes":
                        grade()
                    if next == "no":
                        exit()
                    else:
                        break
name()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source