Common errors in python

               These are special conditions which may occur due to some situations. Some of the commonly known errors are listed below.

  1. 1.       Assertion error
  2. 2.       Attribute error
  3. 3.       Value error
  4. 4.       Tab error
  5. 5.       Import error
  6. 6.       Index error

1.Assertion error:

              When an assertion statement fails, this error occurs.

Eg:

 a = 5

 b =  10

 assert b < a , “b is less than a”

when executing this, you get the assertion error.


2. Attribute Error:

              It occurs while assigning values to attributes or related operations.

Eg:


 Here, append function is not available with float attributes.

3. Value Error :

              User enters data in right datatype,but the value is in wrong datatype. Here, user enters string, but it changed to int.

Eg:

4. Tab error:

              Python follows indentation in each line of code. Generally,4 spaces or 1 tab space used for indentation. If it fails, this error occurs.

Refer my basic errors blog.

https://rajeeva84.blogspot.com/2024/05/basic-errors-in-python.html

5. Import Error:

              When a module imported fails to open, this error occurs.

from greetings import greet1,greet2

greet1.message1()

greet2.message2()


 6.Index error:

              User enters out of range element in a list, this error occurs.

Some of the other errors  involves the user interrupts  keyboard input or programs run out of the memory in the system.

These are common errors in python.

No comments:

Post a Comment