Python Forum
exception in side if clause
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
exception in side if clause
#1
Hi,

I am trying to raise an exception if the no is not in tuple. Where do I include the exception. Tried different ways. Getting indentation error if I put it before else. Now it does not go to the exception at all.

t = (2,3,4)

Ask = int(input("Enter a no:  "))

try:
    if Ask in t:
       print("Valid No")
   
    else:
        print("Not valid")
        print("Enter Again:")
except ValueError as e:
    print(e)
#else:
#    print("Enter Again:")
Reply


Messages In This Thread
exception in side if clause - by sbabu - Feb-13-2020, 04:55 AM
RE: exception in side if clause - by michael1789 - Feb-13-2020, 06:07 AM
RE: exception in side if clause - by buran - Feb-13-2020, 07:59 AM
RE: exception in side if clause - by sbabu - Feb-14-2020, 05:00 AM
RE: exception in side if clause - by ndc85430 - Feb-14-2020, 07:04 PM
RE: exception in side if clause - by sbabu - Feb-15-2020, 02:20 AM
RE: exception in side if clause - by ndc85430 - Feb-15-2020, 08:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Seven Segment Display - QUERY on Multi-line side-by-side printing output ajayachander 3 5,012 Mar-13-2020, 07:02 AM
Last Post: ajayachander
  Blank spaces in right side fernando_santiago18 1 1,700 Sep-07-2019, 12:33 PM
Last Post: ThomasL

Forum Jump:

User Panel Messages

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