hangman: UnboundLocalError: local variable referenced before assignment
<p>I made a program to play hangman. I got pretty far but no matter how many times i try to fix it or make a different variation, the shell just comes up with the same thing.</p>

<p><code>UnboundLocalError: local variable '' referenced before assignment.
</code></p>

<p>I'm fairly new so can you make the answers as simple as possible. (or just a de-bugged version). </p>

<pre><code>import random
tries = 12
def intro ():
    print ('the size of your word is '+str(size))
    print ('you have ' + str(tries) + ' tries')
# word == car     output == '***'  
print (output)
def guesses ():
    guess = ('it')
    while len(guess) &gt; 1:
        guess = str(input('pick a letter ')) 

if guess not in word:
    print ('incorrect')
    tries = tries - 1
    print ('you have ' + str(tries) + ' tries')

if guess in word:
    print ('correct!!')
    tries = tries - 1
    position = word.index(guess)
    output = output[:position] + guess + output[position+1:]
    print ('you have ' + str(tries) + ' tries')

print ('this is a game of hangman where you get a word')
print ('that you have to guess letter by letter')
print ('')
print ('')
word_list = ['jazz', 'whale', 'surgery', 'love']
word = random.choice(word_list)
size = len(word)
output = '*' * size
intro ()    

while output != word or tries != 0:
    guesses ()
    print (output)
</code></pre>

<p>For starters, <code>output</code> is undefined. Note that you never assign to, or otherwise define <code>output</code> before you use it. 
Second, I can't help but to notice you try to use names defined inside of a function outside of it. There are two problems with this:</p>

<ul>
<li><p>Names defined inside of a function do not belong to the global scope </p></li>
<li><p>Even if they did, function <code>guesses</code> executes after you've tried to use an undefined name <code>guess</code></p></li>
</ul>

<p>Take a look at <a href="https://docs.python.org/3/reference/executionmodel.html" rel="nofollow">this</a>.
 I know coding is fun and it's tempting to start writing right away, but If this is your first programming language, don't rush it. If you go slowly and get the hang of Python ( or any other language, excluding some esoteric languages ), you'll be able to transition to any other language easily. Take it slow!</p>

python debugging