Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python, exceptions
#7
(Nov-15-2020, 06:44 AM)KingKhan248 Wrote: If I use the else statement, wouldn't the program ask the user to input values even after a negative number was entered? If for len1 they entered -15 wouldn't the program then ask for len2 and len3, then at the end output the error message?
Yes it will ask for all 3 and then it will check for negative values. @deanhystad showed you one possible approach how to check for negative number immidiatelly. One thing that he does not show is how to keep asking for input until you don't get valid input. But also in his case it will not terminate immediately. It will continue to collect rest values.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Python, exceptions - by KingKhan248 - Nov-15-2020, 06:18 AM
RE: Python, exceptions - by ndc85430 - Nov-15-2020, 06:23 AM
RE: Python, exceptions - by KingKhan248 - Nov-15-2020, 06:28 AM
RE: Python, exceptions - by deanhystad - Nov-15-2020, 06:32 AM
RE: Python, exceptions - by buran - Nov-15-2020, 06:37 AM
RE: Python, exceptions - by KingKhan248 - Nov-15-2020, 06:44 AM
RE: Python, exceptions - by buran - Nov-15-2020, 06:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PiCamera - print exceptions? korenron 2 790 Dec-15-2022, 10:48 PM
Last Post: Larz60+
  Class exceptions DPaul 1 1,257 Mar-11-2022, 09:01 AM
Last Post: Gribouillis
  is this a good way to catch exceptions? korenron 14 4,593 Jul-05-2021, 06:20 PM
Last Post: hussaind
  Split string between two different delimiters, with exceptions DreamingInsanity 2 1,977 Aug-24-2020, 08:23 AM
Last Post: DreamingInsanity
  handling 2 exceptions at once Skaperen 2 2,261 Jun-27-2020, 08:55 AM
Last Post: Yoriz
  remove spaces with exceptions catosp 4 2,357 May-29-2020, 09:32 AM
Last Post: catosp
  Looking for advice and Guidance on Exceptions used within Functions paul41 1 2,107 Nov-14-2019, 12:33 AM
Last Post: Larz60+
  multi-line messages in raised exceptions? Skaperen 3 7,221 Aug-01-2019, 02:17 AM
Last Post: Skaperen
  Creating custom exceptions that co-operate LadySvetlana 4 3,023 Mar-19-2019, 04:24 PM
Last Post: LadySvetlana
  Problems with not having exceptions crash my script league55 7 4,783 Feb-16-2018, 09:06 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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