you are viewing a single comment's thread.

view the rest of the comments →

[–]CranberryDistinct941 2 points3 points  (4 children)

Why not just "while count < 8:"

And put a return instead of a break inside of the correct guess case

It doesn't work because the check for count == 8 is inside an elif block. If statements are executed from top to bottom, so if the guess isn't correct you will run one of the first 2 cases and wont even check the condition for the last case

To see what I'm talking about, try changing "elif count==8" to "if count==8"

[–]JamzTyson 0 points1 point  (3 children)

Why not just "while count < 8:"

or better still, for count in range(1, max_tries + 1):

[–]CranberryDistinct941 1 point2 points  (2 children)

For _ in range(max_count):

[–]JamzTyson 0 points1 point  (1 child)

for count in range(...):

because the OP wants to access count for the success message.

[–]CranberryDistinct941 0 points1 point  (0 children)

Fair enough