How exceptions are handled in python?

Describe how exceptions are handled in python.

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
>>>
What is used to create Unicode string in Python?
Unicode is a system to represent characters from all the world's different languages.......
When to use list vs. tuple vs. dictionary vs. set?
List is like array, it can be used to store homogeneous as well as heterogeneous data type (It can store same data type as well as different data type). .....
Disadvantages of python
Disadvantages of Python are: Python isn't the best for memory intensive tasks........
Post your comment