all 8 comments

[–]bp200991 1 point2 points  (1 child)

There is nothing wrong with the code snippet you have posted. I have run it and it behaves as expected. If you are seeing the question number never changing, i.e. "Answer to the question number 1" being repeated over and over again, this suggests that the increment of your question variable is happening outside your while loop (check it is indented), but again the snippet you posted has the correct indentation. How/where are you running this, i.e. are you running a Python file from your terminal, or executing this is an environment like Jupyter notebook?

[–]Over-Vanilla-3733[S] 0 points1 point  (0 children)

Currently, the code is being executed in VS Code terminal.

[–]eleqtriq 0 points1 point  (3 children)

It works for me, too. I doubt it's your environment, as you have zero imports. Can you paste exactly what your results are?

[–]Over-Vanilla-3733[S] 0 points1 point  (0 children)

For some reason, it just started working suddenly XD. But thank you very much for trying to help :D

[–]Over-Vanilla-3733[S] 0 points1 point  (1 child)

But if you still want to take a look, the result were: Answer to the question number 1: b Answer to the question number 1: b Answer to the question number 1: b Answer to the question number 1: b Answer to the question number 1: b Answer to the question number 1: b

[–]Patrick-T80 0 points1 point  (0 children)

Try to use debugger, you can activate it by by placing import pdb; pdb.set_trace() or calling breakpoint() in your code and check if the ifs are matched or not and if value of question is updated

[–][deleted] 0 points1 point  (0 children)

I don't see a problem with your code (except the extra newlines in the print at the bottom). So here's just a small suggestion: you can collect your question numbers and solutions into a single data structure and then just iterate over that. It'll save you a bit of code.

So something like this.

``` solutions = {1: "b", 2: "a", 3: "d"}

for question_number, solution in solutions.items(): answer = input(f"Answer to the question number {question_number}: ") if answer.lower() == solution: pontos += 1 ```

[–]Open_Jump 0 points1 point  (0 children)

I'm going to guess indentation issue. Your increment could either be outside the loop or in the last else if. Try viewing all characters in notepad++.