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.



Describe how exceptions are handled in python...

Answer / 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

More Python Interview Questions

Explain and statement about list?

0 Answers  


You mentioned pypi in your previous answer. Can you elaborate?

0 Answers  


What is python easy_install?

0 Answers  


How to convert string into datetime?

0 Answers  


What is python namespace?

0 Answers  


Is python good for making apps?

0 Answers  


What is long in python?

0 Answers  


What is the best web framework for Python?

0 Answers  


What does making the cpython different from python?

0 Answers  


What does sorted do in python?

0 Answers  


Is python dict a hashmap?

0 Answers  


How many types of operators python has?

0 Answers  


Categories