[Tutor] Fwd: IF statements
Kent Johnson
kent37 at tds.net
Mon Oct 6 19:17:05 CEST 2008
Forwarding to the list...
---------- Forwarded message ----------
From: Thomas Walch <walch at swipp.de>
Date: Mon, Oct 6, 2008 at 10:35 AM
Subject: Re: [Tutor] IF statements
To: Kent Johnson <kent37 at tds.net>
Entering the code in the interpreter I could not find an issue. No
error at all. Might be that you launched some things in the
interpreter by mistake?
Anyhow, I put the code in an editor and saved it as xxx.py. Again no
error while running the program.
Just try again. Might be different then. I suggest to download SPE:
http://developer.berlios.de/project/showfiles.php?group_id=4161
and try to run it as file too.
Have a nice time....
Thomas
Kent Johnson schrieb:
>
> On Sun, Oct 5, 2008 at 10:51 PM, WM <WFERGUSON1 at socal.rr.com> wrote:
>
>>
>> I used to do Basic and enjoyed it. Someone said Python was a vastly better
>> language than Visual Basic, which I considered playing with. So I sought to
>> give it a go but struck a sticking point very early.
>> I am now going through the Python tutorial. All went well until I came to
>> IF. The code below was not written by me. It is a copy/paste job from the
>> tutor. I do not have any idea what is going wrong.
>>
>> IDLE 2.6 >>>
>>
>>>>>
>>>>> x = int(raw_input("Please enter an integer: "))
>>>>>
>>
>> Please enter an integer: 42
>>
>>>>>
>>>>> if x < 0:
>>>>>
>>
>> ... x = 0
>> ... print 'Negative changed to zero'
>> ... elif x == 0:
>> ... print 'Zero'
>> ... elif x == 1:
>> ... print 'Single'
>> ... else:
>> ... print 'More'
>> ...
>> More
>> 12
>> SyntaxError: invalid syntax
>>
>
> Did you paste the >>> and ... or were they printed by the interpreter?
> Examples often show the entire contents of a session in the
> interpreter, including the >>> and ... prompts. When you enter the
> example yourself you should not include them. Also "Please enter an
> integer: " is output from the program and "42" is user input to the
> program, you should not paste either of them.
>
> Where did the 12 come from? It looks like interpreter output but there
> is nothing preceding it that would print a 12.
>
> Kent
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list