English

When do we get a TypeError?

Advertisements
Advertisements

Question

When do we get a TypeError?

Short Answer
Advertisements

Solution

A TypeError occurs when an operation or function is applied to an object of an inappropriate type.

Examples:

"2" + 3          # TypeError
len(10)           # TypeError
3 + [1, 2]        # TypeError

It can also occur when a function receives the wrong type or number of arguments.

shaalaa.com
  Is there an error in this question or solution?
Chapter 8: Exception Handling & Generate Functions - EXERCISE [Page 158]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 8 Exception Handling & Generate Functions
EXERCISE | Q 6. | Page 158
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×