Re: Wikibooks example doesn't work

2014-08-07 Thread Seymore4Head
On Wed, 06 Aug 2014 21:59:12 -0700, Larry Hudson org...@yahoo.com
wrote:

On 08/06/2014 08:48 PM, Seymore4Head wrote:
 On Thu, 07 Aug 2014 13:43:40 +1000, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:

 Seymore4Head wrote:

 On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
 Seymore4Head@Hotmail.invalid wrote:


[snip]
 Ah, now things make sense! Your subject line is misleading! It's not that
 the wikibooks example doesn't work, the example works fine. It's that the
 code you added to it doesn't do what you expected. You should have said.

 I copied it verbatim from the web page's solution.  After indenting as
 you suggested, it does work now though.
 Thanks


 A counter is added to give 3 tries to guess the number.
 It is supposed to stop after count gets to 3.  It doesn't.  It just
 keeps looping back and asking for another guess.


I just took a look at that web page, and I see what your problem actually is...
You are misunderstanding the problem.  The problem does NOT say to end the 
loop at three tries, 
just to keep track of the number of tries.  It's not actually specific, but 
the implication is 
that AFTER the loop display a message depending on the number of actual tires.

The wikibooks solution IS correct, you understanding of the stated problem is 
not.

My response here may sound harsh but I don't mean it to be, so please don't 
take it that way. 
Python is a great language to learn -- keep it up, you'll get it!:-)

  -=- Larry -=-

It is OK.  I have a thick skin.  I also have a thick skull and need
all the help I can get.

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Wikibooks example doesn't work

2014-08-06 Thread Seymore4Head
number = 7
guess = -1
count = 0
 
print(Guess the number!)
while guess != number:
guess = int(input(Is it... ))
count = count + 1
if guess == number:
print(Hooray! You guessed it right!)
elif guess  number:
print(It's bigger...)
elif guess  number:
print(It's not so big.)
 
if count  3:
print(That must have been complicated.)
else:
print(Good job!)

http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions

Why not?
I think I know why it isn't working, but I don't know enough yet on
how it should work.
The If statement isn't getting read.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Chris Angelico
On Thu, Aug 7, 2014 at 12:58 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
 Why not?
 I think I know why it isn't working, but I don't know enough yet on
 how it should work.
 The If statement isn't getting read.

One thing you need to learn about Python... or, for that matter,
pretty much any language. It isn't working is not very helpful; what
you need to do is show what you expect and what it does. If the script
throws an exception, post the full traceback.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread John Gordon
In ilq5u9lfopj0g8227i5ko9s0lhn1ppc...@4ax.com Seymore4Head 
Seymore4Head@Hotmail.invalid writes:

 number = 7
 guess = -1
 count = 0
  
 print(Guess the number!)
 while guess != number:
 guess = int(input(Is it... ))
 count = count + 1
 if guess == number:
 print(Hooray! You guessed it right!)
 elif guess  number:
 print(It's bigger...)
 elif guess  number:
 print(It's not so big.)
  
 if count  3:
 print(That must have been complicated.)
 else:
 print(Good job!)

 http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions

 Why not?
 I think I know why it isn't working, but I don't know enough yet on
 how it should work.
 The If statement isn't getting read.

It would help tremendously if you gave us more detail than it doesn't
work.

Do you get an error message?
Does the program not execute at all?
Does it execute, but give unexpected results?

-- 
John Gordon Imagine what it must be like for a real medical doctor to
gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Seymore4Head
On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
Seymore4Head@Hotmail.invalid wrote:

number = 7
guess = -1
count = 0
 
print(Guess the number!)
while guess != number:
guess = int(input(Is it... ))
count = count + 1
if guess == number:
print(Hooray! You guessed it right!)
elif guess  number:
print(It's bigger...)
elif guess  number:
print(It's not so big.)

The part to here is supposed to be an example to allow the user to
guess at a number (7) with an infinite amount of tries.


This part was added as an exercise.
A counter is added to give 3 tries to guess the number.
It is supposed to stop after count gets to 3.  It doesn't.  It just
keeps looping back and asking for another guess.

if count  3:
print(That must have been complicated.)
else:
print(Good job!)

http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions

Why not?
I think I know why it isn't working, but I don't know enough yet on
how it should work.
The If statement isn't getting read.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Steven D'Aprano
Seymore4Head wrote:

[snip code that looks fine to me]

 Why not?

I don't know. What does doesn't work mean?

It didn't do what I expected. (What did you expect? What did it do?)

It printed an error message. (Care to tell it what it was?)

It crashed the computer. (Some more details might help.)

My computer caught fire when I ran it. (I'm sorry to hear that.)

Don't expect us to read your mind and know what you know. And don't expect
us to run the code and see for ourselves -- we might, but we normally
shouldn't need to, if you give as the details you already have. And of
course just because it doesn't work on your system, doesn't mean it won't
work on ours.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Steven D'Aprano
Seymore4Head wrote:

 On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
 Seymore4Head@Hotmail.invalid wrote:
 
number = 7
guess = -1
count = 0
 
print(Guess the number!)
while guess != number:
guess = int(input(Is it... ))
count = count + 1
if guess == number:
print(Hooray! You guessed it right!)
elif guess  number:
print(It's bigger...)
elif guess  number:
print(It's not so big.)
 
 The part to here is supposed to be an example to allow the user to
 guess at a number (7) with an infinite amount of tries.
 
 
 This part was added as an exercise.


Ah, now things make sense! Your subject line is misleading! It's not that
the wikibooks example doesn't work, the example works fine. It's that the
code you added to it doesn't do what you expected. You should have said.


 A counter is added to give 3 tries to guess the number.
 It is supposed to stop after count gets to 3.  It doesn't.  It just
 keeps looping back and asking for another guess.

You don't check the counter until after the loop has finished. It needs to
be inside the loop, not outside:

while looping:
# See the indent?
# this is inside the loop

# No indent.
# This is outside the loop.


Also, having reached the count of three, you will want to break out of the
loop. The break command does that.

Is this enough of a hint to continue? Please feel free to ask any further
questions you need.




-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Seymore4Head
On Thu, 07 Aug 2014 13:43:40 +1000, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

Seymore4Head wrote:

 On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
 Seymore4Head@Hotmail.invalid wrote:
 
number = 7
guess = -1
count = 0
 
print(Guess the number!)
while guess != number:
guess = int(input(Is it... ))
count = count + 1
if guess == number:
print(Hooray! You guessed it right!)
elif guess  number:
print(It's bigger...)
elif guess  number:
print(It's not so big.)
 
 The part to here is supposed to be an example to allow the user to
 guess at a number (7) with an infinite amount of tries.
 
 
 This part was added as an exercise.


Ah, now things make sense! Your subject line is misleading! It's not that
the wikibooks example doesn't work, the example works fine. It's that the
code you added to it doesn't do what you expected. You should have said.

I copied it verbatim from the web page's solution.  After indenting as
you suggested, it does work now though.
Thanks


 A counter is added to give 3 tries to guess the number.
 It is supposed to stop after count gets to 3.  It doesn't.  It just
 keeps looping back and asking for another guess.

You don't check the counter until after the loop has finished. It needs to
be inside the loop, not outside:

while looping:
# See the indent?
# this is inside the loop

# No indent.
# This is outside the loop.


Also, having reached the count of three, you will want to break out of the
loop. The break command does that.

Is this enough of a hint to continue? Please feel free to ask any further
questions you need.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread alex23

On 7/08/2014 1:25 PM, Seymore4Head wrote:

This part was added as an exercise.
A counter is added to give 3 tries to guess the number.
It is supposed to stop after count gets to 3.  It doesn't.  It just
keeps looping back and asking for another guess.


You've misread the exercise:

Modify the higher or lower program from this section to keep track of 
how many times the user has entered the wrong number.  If it is more 
than 3 times, print That must have been complicated. at the end, 
otherwise print Good job!



There's nothing there about breaking out of the loop after 3 attempts, 
just producing a different end message on successful completion based on 
how many attempts were made.


The Wikibooks example works as specified.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Larry Hudson

On 08/06/2014 08:48 PM, Seymore4Head wrote:

On Thu, 07 Aug 2014 13:43:40 +1000, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:


Seymore4Head wrote:


On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
Seymore4Head@Hotmail.invalid wrote:



[snip]

Ah, now things make sense! Your subject line is misleading! It's not that
the wikibooks example doesn't work, the example works fine. It's that the
code you added to it doesn't do what you expected. You should have said.


I copied it verbatim from the web page's solution.  After indenting as
you suggested, it does work now though.
Thanks




A counter is added to give 3 tries to guess the number.
It is supposed to stop after count gets to 3.  It doesn't.  It just
keeps looping back and asking for another guess.




I just took a look at that web page, and I see what your problem actually is...
You are misunderstanding the problem.  The problem does NOT say to end the loop at three tries, 
just to keep track of the number of tries.  It's not actually specific, but the implication is 
that AFTER the loop display a message depending on the number of actual tires.


The wikibooks solution IS correct, you understanding of the stated problem is 
not.

My response here may sound harsh but I don't mean it to be, so please don't take it that way. 
Python is a great language to learn -- keep it up, you'll get it!:-)


 -=- Larry -=-

--
https://mail.python.org/mailman/listinfo/python-list


Re: Wikibooks example doesn't work

2014-08-06 Thread Ben Finney
Larry Hudson org...@yahoo.com.dmarc.invalid writes:

 I just took a look at that web page, and I see what your problem
 actually is...

 You are misunderstanding the problem. The problem does NOT say to end
 the loop at three tries, just to keep track of the number of tries.
 It's not actually specific, but the implication is that AFTER the loop
 display a message depending on the number of actual tires.

Could it be re-phrased to state the exercise requirements more clearly?
Maybe you could edit the wiki page to prevent future confusion on this
exercise.

-- 
 \ “Are you pondering what I'm pondering?” “I think so, Brain, but |
  `\   wouldn't his movies be more suitable for children if he was |
_o__)  named Jean-Claude van Darn?” —_Pinky and The Brain_ |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list