By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,096 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,096 IT Pros & Developers. It's quick & easy.

Invalid Syntax

FlamingoRider
P: 11
I keep getting a syntax error on line 11 (while Running = True:) and I'm not sure what's going on. If this is something horribly simple I apologize. I appreciate any help.

Expand|Select|Wrap|Line Numbers
  1. myFears=" "
  2. def addFear():
  3.     if len(myFears) < 1:
  4.         print "You have not entered any fears yet. Please enter one now."
  5.         fear=raw_input("What is a fear of yours?")
  6.         myFears.append(fear)
  7.     else:
  8.         Running = True
  9.         print "Your current fears are", myFears
  10.         toDo=raw_input("Do you want to delete a fear, add one, or leave? (del, add, lev)")
  11.         while Running = True:
  12.             if toDo="add", "ADD", "Add":
  13.                 addFear=raw_input("What is your fear?")
  14.                 myFears.append(addFear)
  15.             elif toDo="del","DEL","Del":
  16.                 delFear=raw_input("What fear have you overcome?")
  17.                 myFears.remove(delFear)
  18.                 print "Fear has been deleted"
  19.             elif toDo="lev","LEV","Lev":
  20.                 print "Goodbye"
  21.                 Running=False
  22.                 break
  23.             else:
  24.                 toDo
  25.  
  26. addFear()
  27.  
  28.  
XP with Cream and Python 2.6
Feb 22 '09 #1
Share this Question
Share on Google+
3 Replies


boxfish
Expert 100+
P: 469
The second most common programming mistake; = is the assignment operator, == is the comparison operator. Use
Expand|Select|Wrap|Line Numbers
  1. while Running == True:
However, you don't even need the comparison. The while loop will continue as long as the condition is true, so you can just write
Expand|Select|Wrap|Line Numbers
  1. while Running:
I hope this helps.
Feb 22 '09 #2

FlamingoRider
P: 11
Wow, that was easy. Thanks a lot. I feel kinda stupid for not catching that myself. Got the bugs out now just gotta tinker with it to get it working the way I need. Thanks for all the help.
Feb 22 '09 #3

boxfish
Expert 100+
P: 469
I'm glad it's running. If you don't want your program to be case sensitive, then instead of writing out all the different case combinations as in
Expand|Select|Wrap|Line Numbers
  1. if toDo="add", "ADD", "Add":
just convert the input to lowercase with the lower() function and compare it with a lowercase string:
Expand|Select|Wrap|Line Numbers
  1. if toDo.lower() == "add":
I hope this is helpful.
Feb 22 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.