Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Python

Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-2008, 02:50 PM
the.anti.9's Avatar   
the.anti.9 the.anti.9 is offline
Newbie
 
Join Date: Jan 2008
Age: 17
Posts: 14
Rep Power: 0
the.anti.9 is on a distinguished road
Send a message via AIM to the.anti.9
Question repetative user input

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

This is what i have:
Code:
while ((input = raw_input(":")) != "exit")
  ...
This is the error i get:
Code:
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-11-2008, 12:59 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: repetative user input

Code:
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.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-13-2008, 11:21 AM
varon89 varon89 is offline
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0
varon89 is on a distinguished road
Default Re: repetative user input

Quote:
Originally Posted by the.anti.9 View Post
Code:
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

Code:
while condition:
    more code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
using goto/if else and user input in C# Siten0308 CSharp Tutorials 7 07-28-2008 10:33 AM
Question about C# user int input TheMagicalRock C# Programming 3 04-01-2008 09:36 AM
how to write the code for user to input command ? worried_student C and C++ 3 12-26-2007 09:11 PM
[C++] Validating user input Xochiquetzal C and C++ 2 07-08-2007 06:18 PM
Java:Tutorial - User Input John Java Tutorials 0 12-09-2006 08:25 PM


All times are GMT -5. The time now is 02:35 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads