Q:

python looping with functions break and continue outside loop

I am new to programming and so i'm practicing a bid. At this point i'm practicing with functions. In the code below break and continue are outside the loop i can not see why. I've tryed out different ways but the only thing i get to work is the last block of code. Why are break and continue outside the loop here?
    import random
again = 'y'

while again == "y" :
    def main():
        print "gues a number between 0 - 10."
        nummer = random.randint(1,10)
        found = False

        while not found:
            usergues = input("your gues?")
            if usergues == nummer:
                print 'Your the man'
                found = True
            else:
                print 'to bad dude try again'

main()  
again = raw_input('would you like to play again press y to play again   press n yo exit')
if again == 'n':
    break   #here it says it is outside the loop 
elif again != 'y':
    print 'oeps i don\'t know what you mean plz enter y to play again or n to exit'
else:
continue        #this is outside loop as well

#main()

A:

Because you are new to programming, I will get a few basic tips in my answer too.
INFINITE LOOP
You are trying to start an infinite loop by first settingagain = 'y' and afterwards you are using this variable to evaluate a while loop. Because you are not changing the value of y, it is better to not use a variable to create this infinite loop. Instead, try this:
while True:
    (some code)

DEFINE FUNCTION IN LOOP
You're defining the function main() inside of the while loop. As far as I can tell, there is no use for that. Just leave out the first while loop. If you define a function, it is permanent (much like a variable), so no need to redefine it everytime. Using your code, you won't even get to call the function, because you never end the first loop.
CONTINUE/BREAK NOT IN LOOP
The error is quite self-explanaitory, but here we go. If you would ever end the first loop (which in this case, you won't), the next thing you do is call your function main(). This will generate a number and make the user guess it until he got it right. When that happens, you get out of that function (and loop). 
Next, you ask if the user would like to play again. This is just an input statement. You store the answer in the variable 'again'. You check, with an if statement (note that this is not a loop!) what the answer is. You want the user to play again if he typed 'y', so instead of using again != 'y', you could use the following:
if again == 'y':
    main()  # you call the function to play again

If 'n' was typed in, you want to exit the script, which you do not by typing break, because you are not in a loop, just in an if-statement. You can either type nothing, which will just go out of the if-statement. Because there is nothing after the if, you will exit the script. You could also useexit(), which will immediately exit the script.
Lastly, you want to repeat the question if neither of these two things were answered. You can put the if-statement inside of a loop. You can (if you want) use your break and continue when doing this, but you mostly want to avoid those two. Here is an example:
while True:
    again = raw_imput('y for again or n to stop')
    if again == 'y':
        main()
        exit()  # use this if you don't want to ask to play again after the 2nd game
    elif again == 'n':
        print('bye!')
        exit()
    # no need for an 'else' this way
    # every exit() can be replaced by a 'break' if you really want to

BASIC BREAK/CONTINUE USAGE
Finally, here is some basic usage of break and continue. People generally tend to avoid them, but it's nice to know what they do.
Using break will exit the most inner loop you are currently in, but you can only use it inside of a loop, obviously (for-loops or while-loops).
Using continue will immediately restart the most inner loop you are currently in, regardless of what code comes next. Also, only usable inside of a loop.
EVERYTHING TOGETHER
import random
again = 'y'

def main():
    print ("gues a number between 0 - 10.")
    nummer = random.randint(1,10)
    found = False
    while not found:
        usergues = input("your gues?")
        if usergues == nummer:
            print ('Your the man')
            found = True
    else:
        print ('to bad dude try again')

main()
while True:
    again = input('would you like to play again press y to play again   press n yo exit')
    if again == 'n':
        print ('bye!')
        exit()  # you could use break here too
    elif again == 'y':
        main()
        exit()  # you can remove this if you want to keep asking after every game
    else:
        print ('oeps i don\'t know what you mean plz enter y to play again or n to exit')

I hope I helped you!

