473,657 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid Syntax

FlamingoRider
11 New Member
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 4539
boxfish
469 Recognized Expert Contributor
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
11 New Member
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 Recognized Expert Contributor
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
590
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 wxPython2.4 and Boa 0.2.3
4
10702
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 within the form is a button bar and a <div> block which contains a table of parameters. The div block is used to create a layer.
7
36696
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 to duplicate -- it just show up... I've heard that spurious queries that use Now() or Date() or some other date
0
1597
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 just two ASPX pages, Login.aspx and Main.aspx (both dynamically generated on each load). Users first hit Login.aspx which prompts for login details, and then performs some custom authenication and creates some session variables. If authentication is...
5
20338
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 syntax
2
2471
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 ------------------ import wmi # the ip of my own local desktop
5
2360
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 issue? I believe A1 is no. I tried below with template function "f". For A2, functors work but have ugly syntax and runtime overhead. A
10
6406
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 stuck. Can anyone help? #!/usr/local/bin/python # Copyright 2004 by Stephen Masterman #Change the db connection details here.
7
3907
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
6213
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 = int(raw_input("Do you want to calculate primes? 1 = yes and 2 = no. "))
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.