Having trouble with Python functions in my Guess The Number Game P
<p>I'm having troubles getting a proper readout, guessed keeps coming up as undefined but I have definitely defined it there.</p>

<p>Sorry about the terrible code, I'm really really new to this.</p>

<p>If there are any problems past my probably really easy to see simple mistake, please inform me about that too!</p>

<p>Thank you!!!</p>

<pre><code>import random


def main():

    print "Hello what is your name?"
    name = raw_input()

    print ""
    number = input("Well, "+name+", I am thinking of a number between 1 and 100. Please type your first guess: ")
    guess(number)

def guessing(number1):

    guessed = False
    num_guesses = 0
    randomNumber = random.randrange(1, 100)
    while num_guesses &lt; 7 and not guessed:
        print "Please enter a guess."
        guess = int(raw_input())
        num_guesses += 1
        if guess == num:
          guessed = True
        elif guess &gt; num:
          print "Too High"
        else:
          print "Too Low"
        if guessed:
          if num_guesses &gt; 1:
            print "Congratulations! You got the number in", num_guesses,    "guesses."
          else:
            print "Congratulations! You got the number in 1 guess."
        else:
            print "You did not guess the number in",num_guesses,"guesses."

    playAagain = raw_input ("Excellent! You guessed the number! Would you like to play again (y or n)? ")
    if playAagain == "y":
            main()

    main()
</code></pre>

<p>I think I know why you have a problem: you probably <em>renamed</em> your <code>guess</code> method by <code>guessing</code> but <em>not in the <code>main</code> function</em>.</p>

<p>But since PyScripter (or your editor) has previously run with the previous name, it has a copy of the old method in memory, hence the strange errors you're experiencing.</p>

<p>Quit your editor (or just type <code>del guess</code> in the editor python console) and you'll have coherent errors, the first one being calling <code>guess(number)</code> instead of <code>guessing(number)</code>, but there are others... Good luck with your program.</p>

python function