Ask coding questions

← Back to all posts
need help and idk what the problem is
Kavin1983 (1)

I'm a beginner to programming and I created a math quiz project where I have a list and using a function I print all the questions, I also printed out how many questions you get right at the end of the quiz by printing a list that had variables appended whenever a question right. Anyway I don't see any solution around this and I need help.

Answered by InvisibleOne (2683) [earned 5 cycles]
View Answer
InvisibleOne (2683)

input() returns a string, so checking if times are correct won't work since you are checking if a string is equal to a number, you can fix this by putting input inside of int()
so line 19 should be: user_input = int(input(f"{question_to_calculate['question']}: ") and then remove the 'str(user_input) from your if statement because or else it will be removing what you did.
Next, instead of appending "1" to your correct list each time, instead just make correct a number and add one to it with
correct += 1 then at the end you can just print out "You got: " + str(correct) + " Correct!"
Anyways, your whole program is a bit complicated, you might want to think about redoing it.

InvisibleOne (2683)

Here's a simplified version of what I think you want it to do:

Kavin1983 (1)

Thanks for all the help, really appreciate it!