These exceptions are caused when the type of some object should be different

TypeError: [definition/method] takes ? positional arguments but ? was given

A function or method was called with more (or less) arguments than the ones it can accept.

Example

If more arguments are given:

def foo(a): return a
foo(a,b,c,d) #And a,b,c,d are defined

If less arguments are given:

def foo(a,b,c,d): return a += b + c + d
foo(a) #And a is defined

Note: if you want use an unknown number of arguments, you can use *args or **kwargs. See *args and **kwargs


TypeError: unsupported operand type(s) for [operand]: ‘???’ and ‘???’

Some types cannot be operated together, depending on the operand.

Example

For example: \\+ is used to concatenate and add, but you can’t use any of them for both types. For instance, trying to make a set by concatenating (\\+ing) 'set1' and 'tuple1' gives the error. Code:

set1, tuple1 = {1,2}, (3,4)
a = set1 + tuple1

Some types (eg: int and string) use both \\+ but for different things:

b = 400 + 'foo'

Or they may not be even used for anything:

c = ["a","b"] - [1,2]

But you can for example add a float to an int: