On Sun, Jun 22, 2008 at 6:45 AM, Danny Laya <[EMAIL PROTECTED]> wrote:
> Hi ! I have learned wiki tutor for non-programmer and I found some hill that
> stopping me. In  Non-Programmer's Tutorial for Python/Count to 10, wiki ask
> me to write this code :
>
> a = 1
> s = 0
> print 'Enter Numbers to add to the sum.'
> print 'Enter 0 to quit.'
> while a != 0:
>     print 'Current Sum:', s
>     a = int(raw_input('Number? '))
>     s = s + a
> print 'Total Sum =', s
>

The above code, copy/pasted to a file, and run from the command-line
gives the following output:

Enter Numbers to add to the sum.
Enter 0 to quit.
Current Sum: 0
Number? 1
Current Sum: 1
Number? 2
Current Sum: 3
Number? 3
Current Sum: 6
Number? 4
Current Sum: 10
Number? 0
Total Sum = 10

> But when i write while a != 0: and then i press enter,
> python terminal tell me :
>>>> while a ! = 0:
>   File "<stdin>", line 1
>     while a ! = 0:
>             ^
> SyntaxError: invalid syntax
>
> Can you
>  find my mistake, guys ? Sorry to bother you, I try to
> find the answer in google, but I can't found the answer.
> Please help me soon guys, whatever your answer. If you don't
> want to answer my question, please give me some site that could
> answer this newbie question. Thank's.
>

The syntax error seems to be the space between the '!' and the '='.
'!=' means 'does not equal'

'! =' doesn't mean anything, thus, the syntax error.

When you're beginning, you'll make plenty of errors like that.
Stop and read the error carefully, then look at the code closely.

As you gain experience, you'll learn to see those nit-picky syntax errors.
It doesn't matter which computer programming language you start out with,
each one has a specific syntax that must be followed, or you'll get syntax
errors. Python is very friendly, and the error messages it gives you are
much more helpful than other languages.

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to