Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

repetative user input

user input

  • Please log in to reply
2 replies to this topic

#1 the.anti.9

the.anti.9

    CC Newcomer

  • Just Joined
  • PipPip
  • 13 posts

Posted 10 August 2008 - 10:50 AM

I want to keep getting user input until the person says exit but I keep getting an error.

This is what i have:
while ((input = raw_input(":")) != "exit")
  ...

This is the error i get:
C:\Users\ryan>e:\images\scripts\mysql.py
  File "E:\images\scripts\mysql.py", line 5
    while ((input = raw_input(":")) != "exit")
                  ^
SyntaxError: invalid syntax

What should I do to fix this?
  • 0

#2 v0id

v0id

    Retired

  • Retired Mod
  • PipPipPipPipPipPipPipPip
  • 2313 posts

Posted 10 August 2008 - 08:59 PM

user_input = ""
while user_input != "exit":
    user_input = raw_input(":")
    # ...
I changed your variable input to user_input, as a standard function with the name input already exists in Python.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#3 varon89

varon89

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 13 August 2008 - 07:21 AM

while ((input = raw_input(":")) != "exit")
  ...


That's also not python syntax. In python, you can't set variables within conditional statements, nor do you put parentheses about the statement; it's just

while condition:
    more code

  • 0





Also tagged with one or more of these keywords: user input

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download