communicating between functions in python
<p>I am doing a school project and I need some help communicating between functions. This is what I have got so far</p>

<pre><code>def difficuilty():
level = 0
while level &gt;=4 or level == 0:
    level = int(input("Please enter the difficulty (1/2/3)"))
    if level == 1:
        yesNo = input("you have chosen difficulty 1, is this correct? ")
        if yesNo.upper() == 'Y':
            level  = 1
        elif yesNo.upper() == 'N':
            level  = 4
        else:
            print ("You have entered the wrong thing")
    elif level == 2:
        yesNo = input("you have chosen difficulity 2, is this correct? ")
        if yesNo.upper() == 'Y':
            level  = 2
        elif yesNo.upper() == 'N':
            level  = 4
        else:
            print ("You have entered the wrong thing")
    elif level == 3:
        yesNo = input("you have chosen difficulity 3, is this correct? ")
        if yesNo.upper() == 'Y':
            level  = 3
        elif yesNo.upper() == 'N':
            level  = 4
        else:
            print ("You have entered the wrong thing")

return level 


def question(level):
    if level == 1:
        print ("hi")

def main():

    getName()
    difficulty()
    question(level)
</code></pre>

<p>I am trying to get the variable 'level' from the difficulty function to go into the question function so I can use it, when I run the program, it gives me an error which says 'NameError: Name 'level is not defined'. Can someone please help me. Thanks</p>