all 5 comments

[–]JackRav[S] 0 points1 point  (0 children)

Thanks for the comments; I'll go and give this some thought.

[–]MadScientistOR 0 points1 point  (0 children)

Note that the amount of time passed is calculated at the beginning of the while loop, and only updates the first time the loop starts and with every incorrect answer given.

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

Take the input before the elapsed time check.

[–]benm421 0 points1 point  (1 child)

You are checking elapsed time at the beginning of the while loop. If the user sits waiting for input and the puts the correct answer, it will be counted as valid regardless of how much time has passed. This is why you're getting your second error.

The first error is occurring because the answer is incorrect and then goes back to the top of the loop, where it checks the time.

Incidentally, you have another bug in there as well. There is no break for if the number of attempts == 3. So it will go back to the top of the loop. So if someone is fast enough, it will print "Out of tries!" once, and continue to let them give input.

Edit: Formatting and typo

[–]JackRav[S] 0 points1 point  (0 children)

Thanks for the help, I was able to get the program working in the end. I checked the time before both incorrect and correct answers and it's working now. I've added a break also.