Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Describe how exceptions are handled in python.

Answer Posted / chaitanya

Errors detected during execution of program are called exceptions. Exceptions can be handled using the try..except statement. We basically put our usual statements within the try-block and put all our error handlers in the except-block.

try…except demo code:

>>> while True:

try:

x = int(raw_input("Enter no. of your choice: "))

break

except ValueError:

print "Oops! Not a valid number. Attempt again"

Enter no. of your choice: 12ww

Oops! Not a valid number. Attempt again

Enter no. of your choice: hi there

Oops! Not a valid number. Attempt again

Enter no. of your choice: 22

>>>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What opens a py file?

1004


Is Python good for backend?

879


Why do we use raw_input in python?

921


List out atleast two loop control statements?

918


How to append to a string in Python?

936


What are middlewares in python?

801


How to give comments in python?

889


Is r similar to python?

847


How can you create empty numpy array in python?

966


How is a .pyc file different from a .py file?

861


What does the keyword do?

855


Is python duck typed?

848


What are the different environment variables identified by python?

844


What is iterable python?

997


What do you understand by the process of compilation and linking in python?

777