0

Hello all, well, I am new to these forums, and fairly new to Python. I know some python though, so I am not a complete "newb" so to speak. But I was wondering how to have python while loops work for two variables or strings or w.e. here's a piece of some simple code right now that I am working on.

import sys
a = "/help"
b = "awesome1"
print ("This is a test script for multiple while loops")
an = raw_input("type /help to continue:\n ")

if an == a:
    import hfile
elif an == b:
    import helloworld
while an != a:
    print("That is invalid!\n")
    an = raw_input("type /help to continue or the password:\n ")
    break

so, basically what I want it to do is have the while have two conditions. in this case Condition a and b. Thanks in advance,
-Coolprogram

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by woooee
0

I think you just want a simple menu program

def func_a():
   print "     hello world import"
def func_b():
   print "     hfile import"

##-------------------------------------------------------------------
menu_d = { "awesome1":'func_a()', 
           "/help":'func_b()'} 
choice = ""
while choice not in menu_d:
   choice = raw_input("type /help to continue or the password:\n ")
   if choice in menu_d:
      eval(menu_d[choice])
   
print "\nend of program"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.