[Tutor] Extremely simple question
Steven D'Aprano
steve at pearwood.info
Wed Jan 11 11:24:27 CET 2012
Noah Hall wrote:
> On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson <c.johnsonbl at gmail.com> wrote:
>> Hi there,
>>
>> I am *new* (I cannot put enough emphasis on that!) to Python programming,
>> and to programming in general. I am trying to write out a statement that
>> will protect a file on my computer from being run unless I enter the right
>> specifications;
>>
>>> your_weight = int(raw_input("Please enter your weight: "))
>>> if your_weight < 0:
>>> print 'You're not Chris!'
>>> elif your_weight == 170:
>>> print 'You might be Chris! But...'
>>> your_height = int(raw_input("Please enter your height: "))
>>> if your_height < 180:
>>> print 'You're not Chris!
>>> elif your_height == 180:
>>> print 'You're Chris!'
>>> your_name = int(raw_input("What is your name? "))
>>> elif your_height > 180:
>>> print 'You're not Chris!"
>>> elif x > 170:
>>> print 'You're not Chris!'
>>
>> When I open it, the program says I have a syntax error. Praytell, where did
>> I go wrong?
>
> When you have a problem like this, you should copy and paste the
> *whole* traceback here. Anyway, just from quickly looking, I think
> your error lines in the the line
>
> elif x > 170:
>
> I'm sure you can work out why.
Well, I can't. Chris reported that he gets a SYNTAX error, and for the life of
me I can't work out what SyntaxError you think he'll be getting from that line.
Based on Chris' post, he has a whole lot of code starting with ">", which of
course will give a SyntaxError. He also hasn't indented his if/elif blocks.
But of course his mail client might be mangling his code. Without being able
to see the code, and the actual error message in full, we're all just
guessing. And frankly, my crystal ball is out of order.
--
Steven
More information about the Tutor
mailing list