Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error **function is not defined error in Python** **in python**. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Table of Contents

## How function is not defined error in Python Error Occurs?

Today I get the following error **function is not defined error in Python** **in python**.

## How To Solve function is not defined error in Python Error ?

**How To Solve function is not defined error in Python Error ?**To Solve function is not defined error in Python Error In python functions aren't accessible magically from everywhere (like they are in say, php). They have to be declared first. So this will work:

**function is not defined error in Python**To Solve function is not defined error in Python Error In python functions aren't accessible magically from everywhere (like they are in say, php). They have to be declared first. So this will work:

## Solution 1

In python functions aren’t accessible magically from everywhere (like they are in say, php). They have to be declared first. So this will work:

def pyth_test (x1, x2): print x1 + x2 pyth_test(1, 2)

But this won’t:

pyth_test(1, 2) def pyth_test (x1, x2): print x1 + x2

## Solution 2

It works for me:

>>> def pyth_test (x1, x2): ... print x1 + x2 ... >>> pyth_test(1,2) 3

Make sure you define the function **before** you call it.

**Summery**

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

**Also, Read**