Re: [Tutor] Extremely simple question

2012-01-11 Thread Adam Stogner
You should be using double quotes on this line and you are missing the last
quote:

print 'You're not Chris!

Should be:

print "You're not Chris!"


On Wed, Jan 11, 2012 at 8:17 AM, col speed  wrote:

> On 11 January 2012 20:11, Max S.  wrote:
> > I believe that line 3 raises an error.  The because you contained the
> text
> > in single quotes, and then used the same character in 'you're not chris',
> > Python believes that you are trying to type "you" re not chris".  You can
> > change the single quotes surrounding your string to double quotes
> ("you're
> > not chris"), triple-single quotes ('''you're not chris'''), or
> triple-double
> > quotes ("""you're not chris"""), or you can tell Python that you want to
> > include the apostrophe in your string by preceding it with a \ ('you\'re
> not
> > chris').  The latter works on the same idea as \n and \t.
> >
> How didn't I see that?
> It just goes to show a gooddun from a baddun.
> Cheers
> Col
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-11 Thread col speed
On 11 January 2012 20:11, Max S.  wrote:
> I believe that line 3 raises an error.  The because you contained the text
> in single quotes, and then used the same character in 'you're not chris',
> Python believes that you are trying to type "you" re not chris".  You can
> change the single quotes surrounding your string to double quotes ("you're
> not chris"), triple-single quotes ('''you're not chris'''), or triple-double
> quotes ("""you're not chris"""), or you can tell Python that you want to
> include the apostrophe in your string by preceding it with a \ ('you\'re not
> chris').  The latter works on the same idea as \n and \t.
>
How didn't I see that?
It just goes to show a gooddun from a baddun.
Cheers
Col
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-11 Thread Max S.
I believe that line 3 raises an error.  The because you contained the text
in single quotes, and then used the same character in 'you're not chris',
Python believes that you are trying to type "you" re not chris".  You can
change the single quotes surrounding your string to double quotes ("you're
not chris"), triple-single quotes ('''you're not chris'''), or
triple-double quotes ("""you're not chris"""), or you can tell Python that
you want to include the apostrophe in your string by preceding it with a \
('you\'re not chris').  The latter works on the same idea as \n and \t.

On Wed, Jan 11, 2012 at 6:04 AM, col speed  wrote:

> 
> > 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?n
> I'm a newbie, but I get "NameError" because 'x' is not defined.
> Also "your_name = int(raw_input("What is your name? "))" will give this :
> ValueError: invalid literal for int() with base 10: 'name'.
> As you can't change a string to be an int.
> I can't find a syntax error, but next time, please paste the whole
> traceback as this helps people with less time than me to sort out
> problems.
>
> Good luck with Python
> Col
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Extremely simple question

2012-01-11 Thread Mike G
Hi Chris

I'm new to programming and Python myself so I would listen to the
previous guys first, and I'll repeat a bit of what has already been
mentioned...

Make sure you define 'x'. Is name really an 'int', or is it possibly a 'str'?

Fix any indentation issues.

Is there anything you can do with quotes - single or double:
print "You're not Chris!" or print 'You\'re not Chris!'

You should be able to make your code work as is but it would also look
nice in a function, passing the user 'raw_input' to a function -

def chris(name, height, weight):
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-11 Thread col speed

> 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?n
I'm a newbie, but I get "NameError" because 'x' is not defined.
Also "your_name = int(raw_input("What is your name? "))" will give this :
ValueError: invalid literal for int() with base 10: 'name'.
As you can't change a string to be an int.
I can't find a syntax error, but next time, please paste the whole
traceback as this helps people with less time than me to sort out
problems.

Good luck with Python
Col
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-11 Thread Noah Hall
On Wed, Jan 11, 2012 at 10:24 AM, Steven D'Aprano  wrote:
> Noah Hall wrote:
>>
>> On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson 
>> 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.

I had assumed that to him, a Syntax Error == any error, so guess it
was probably a name error as x isn't defined.

(Also, for me his post was indented correctly - probably down to my
client, though)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-11 Thread Steven D'Aprano

Noah Hall wrote:

On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson  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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Extremely simple question

2012-01-10 Thread Noah Hall
On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson  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.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Extremely simple question

2012-01-10 Thread Chris Johnson
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?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor