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 |
Explain and statement about list?
You mentioned pypi in your previous answer. Can you elaborate?
What is python easy_install?
How to convert string into datetime?
What is python namespace?
Is python good for making apps?
What is long in python?
What is the best web framework for Python?
What does making the cpython different from python?
What does sorted do in python?
Is python dict a hashmap?
How many types of operators python has?