Hey guys

Andrew here, with another problem.

My while loop is made so that it is on, or off, simple eh? That's what I thought, but it doesn't seem to be acting as I would expect it to!

The problem is, when I want it to loop, in testing it didn't loop, which is a problem!

This is my code:

print "HOW MANY VARIABLES WOULD YOU LIKE?"
print "2"
print "3"
print "4"
print "5"
print "6"
print "7"
print "8"
print "9"
print "10"
print "--------------------------------------------------------------------------------"
MainLoop = 1
while MainLoop == 1:
    variables = raw_input (" ")
    if variables == "2":
        name1 = raw_input ("NAME YOUR FIRST VARIABLE ")
        time.sleep(1)
        name2 = raw_input ("NAME YOUR SECOMD VARIABLE ")
        time.sleep(1)
        print "--------------------------------------------------------------------------------"
        NameInHat = raw_input ("PLEASE PRESS ENTER TO PICK YOUR RANDOM VARIABLE ")
        loop = 1
        while loop == 1:
            randomg = random.randint(1, 2)
            if randomg == 1:
                print name1
            elif randomg == 2:
                print name2

            end = raw_input ("WOULD YOU LIKE TO FINISH? ")
            if end == "YES" or "yes" or "y" or "Y":
                loop = 2
            elif end == "no" or "NO" or "n" or "N":
                print " "
        print "THANK YOU USING MY APP."
        menu = raw_input ("WOULD YOU LIKE TO GO BACK TO THE MENU? ")
        if menu == "no" or "NO" or "n" or "N":
            MainLoop = 2
            exit
        elif menu == "YES" or "yes" or "y" or "Y":
            print " "

Hope this is fixable. And could someone also provide an explanation as to why it isn't working, and how they fixed it!

What happens when "variables != '2'" ?

## Three variables
print "HOW MANY VARIABLES WOULD YOU LIKE?"
for ctr in range(3):
    print ctr+1

names_list=["FIRST", "SECOND", "THIRD"]
MainLoop = 1
while MainLoop == 1:
    name_of_variables=[]
    variables = raw_input ("Enter Variables ")
    for ctr in range(int(variables)):
        name = raw_input ("NAME YOUR %s VARIABLE " % (names_list[ctr]))
        name_of_variables.append(name)

    ## exit testing while() loop
    MainLoop = 0

print name_of_variables

Oh I have all of that, it is essentially, variable 1 copied, and adding a third possible variable!

The point is MainLoop is not changed if variables does not equal 2.

also

  anything or 'no'

is always True as 'no' is not empty string.

instead of confusing while MainLoop == 1 you can use:

while True:
    '''do stuff'''
    break