in a while loop, where should you place a variable for counting?

Wouldn’t it have been far easier to just copy in the text than to print-screen and crop the image? The number of tries is initialized to 1 which is misleading as at that point in the program there hasn’t been any tries. Logically it makes more sense to initialize tries to 0 and place the increment immediately after the user input. But because the program hasn’t been structured in this way, tries must be incremented after comparing the guess to the target; otherwise, in the case when the user’s guess is correct, the output would show a number of tries one greater than the actual number of tries.

Leave a Comment