Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Program

Status
Not open for further replies.

thomasrules

Programmer
Joined
Nov 4, 2006
Messages
1
Location
CA
Hi I'm starting up learning Python. I'm making a small program that basicaly asks the user if he wants to run the program or turn it off and I want to loop it, so that it keeps on asking if I want to make it run or not. If I say no then the loop ends.:


print "Run the program?\n\n"

y="yes"
n="no"
x =""
while x != "no":
x = raw_input('(y)es or (n)o?:\n')
print "Starting Up"


while x !="yes":
x = raw_input('(y)es or (n)o?:\n')
print "Shuttind Down"
 
You want this ?
Code:
print "Run the program?\n\n"
x =''
while x!='y' and x != 'n':
  x = raw_input('(y)es or (n)o?:\n')
  x.lower()
  if x == 'y':
    print "Starting Up"
  elif x == 'n':
    print "Shuttind Down"

or this ??

Code:
print "Run the program?\n\n"
x ='y'
while x != 'n':
  x = raw_input('(y)es or (n)o?:\n')
  x.lower()
  if x == 'y':
    print "Starting Up"
  elif x == 'n':
    print "Shuttind Down"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top