Q:

I don't understand why I'm getting "x is not defined" in Python

I've just started programming in Python and I'm getting x is not defined but I have no idea why it is saying that considering I think it is defined.
def menu():
    x = 0
    while x != 1 or 2:
        print "menu"
        print "1)login"
        print "2)under dev"
        x = raw_input('select menu option')
        if x == 1 or 2:
            break
menu()
if x=='1':
    print "enter username:"
y = raw_input()
if y=="username":
    print "enter password:"
z = raw_input()
if z=="password":
    print "password accepted"
elif x=='2':
    print "under development"
elif y or z == False:
    print "username or password incorrect"

A:

x is a local variable in the menu() function, it doesn't exist outside of menu().
You could return it from menu() then store the value in a new x in your code:
def menu():
    x = None
    while x not in ('1', '2'):
        print "menu"
        print "1)login"
        print "2)under dev"
        x = raw_input('select menu option')
    return x

x = menu()

Note that I fixed several problems with your code in menu() as well.

raw_input() returns a string, but you test if x is integer 1 or 2 instead. I changed the code to test for the strings '1' and '2' instead.
Don't use x != 1 or 2, that does not mean what you think it means. It tests if x != 1 is True, and if not, it tests if 2 is True. 2 is always True because all non-zero numbers are considered True in a boolean context.
I replaced that with a x not in ('1', '2') test.
There is no need to test x inside the loop again and execute a break; the while loop will just exit on its own without that test.
It doesn't really matter what x is set to at the start of menu(), as long as it is not '1' or '2'. None is a good choice to signal that it is 'empty'.

