473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Invalid Syntax

FlamingoRider
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
3 4531
boxfish
469 Expert 256MB
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
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
469 Expert 256MB
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

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

Similar topics

0
by: ray sleeper | last post by:
This is the syntax i'm using: python setup.py p2exe i get "invalid synyax " message. According to the Py2exe website this the correct syntax. using python 2.2 on WinXP box with...
4
by: Bradley Kite | last post by:
Hi all. I'm trying to diagnose/solve a problem with internet explorer, whereby sometimes the form submits, and other times IE produces an 'invalid syntax' error. First, I have a form, and...
7
by: deko | last post by:
I'm getting intermittent "Object Invalid or No Longer Set" errors in my Access 2002 mdb. What causes these errors? Has anyone dealt with this before? I can't trace it because it's not easy...
0
by: Mark Phanides | last post by:
My ASP.NET application intermittantly (but always at same point) redirects to the 'Invalid Syntax Error' web page for some unknown reason. I've created a ASP.NET application written in VB.NET with...
5
by: DIBS | last post by:
I'm new to Python and I don't understand what I'm doing wrong. I'm running windows xp. In the command line window, I type: Python Sudoku.py and I get the response" SyntaxError: invalid...
2
by: py | last post by:
Hi, I am running python 2.4.2 on win xp pro. I have the WMI module from Tim Golden (http://tgolden.sc.sabren.com/python/wmi.html). I have some code which does this... MyScript.py...
5
by: chrisstankevitz | last post by:
Hi, Q1: Is there a way to make a template function that works only for specific types which produces a compiler error if used with an invalid type? Q2: If not, how do people deal with this...
10
by: ronrsr | last post by:
no matter where I place this imported file,the statement after it in the main program gets a syntax error, regardless of the syntax. I think I may have changed something in this file, but I'm...
7
by: alf | last post by:
Hi, I wonder why it is an invalid syntax: File "<stdin>", line 1 if 1: if 1: if 1: print 1 or
6
by: Nathan Pinno | last post by:
Why does my compiler say invalid syntax and then highlight the quotation marks in the following code: # This program is to find primes. primes = import math import gmpy while 1: run =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.