I am trying to fish a project where I create an app that lets the user input how many questions they want to answer and randomly generate questions for them to answer as well. At the end it will tell them how many they got correct out of the amount of questions they picked.
The problem I have having is that no matter what it tells me the answer is incorrect. I’m not sure why
import random count = 0 questionFlag = True ##This flag makes sure the user can reenter their amtQuestions again correct = 0 #Counter for correct questions incorrect = 0 ##Counter for incorrect questions amtQuestions = input("How many probems would you like to solve?: ") try: amtQuestions = int(amtQuestions) except: print("ERROR: Enter only numerical values") amtQuestions = input("How many questions would you like to solve?: ") questionFlag = False else: ##Numbers and equations percent = random.randint(1,99) percent2 = percent//100 wholeNum = random.randint(1,999) ##Questions loop for range in (amtQuestions,0,-1): ##Counting down based on how many questions the user said they would like to solve userAnswer = float(input("What is " + str(percent) + " percent of " + str(wholeNum) + "?: ")) answer = wholeNum * percent2 if userAnswer == answer: print("That is correct") correct +=1 elif userAnswer != answer: print("That is incorrect") incorrect +=1 print("You got " + str(correct) + " out of " + str(amtQuestions)+ " answers correct")