Python Forum
except condition in not executing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
except condition in not executing
#8
(Oct-26-2020, 12:51 PM)GOTO10 Wrote:
(Oct-26-2020, 12:43 PM)MahaEbrahim Wrote: the issue here is that the exception can not see the else conditions if the user exceeded the allowed numbers of Attempts which is 2.

Think about what happens after the user gets their second ValueError. You increment the variable z so that it is now equal to 2, then your while loop on line 5 starts over. Since the while condition is no longer True (z is no longer less than 2), the while loop is skipped and execution resumes at line 19.

I can see it now. I changed the else to if . and it worked.
Reply


Messages In This Thread
except condition in not executing - by MahaEbrahim - Oct-26-2020, 01:59 AM
RE: except condition in not executing - by GOTO10 - Oct-26-2020, 12:51 PM
RE: except condition in not executing - by MahaEbrahim - Oct-26-2020, 01:38 PM
RE: except condition in not executing - by Larz60+ - Oct-26-2020, 10:14 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020