Vincent Balmori wrote:
Here is my updated code. As simple as this may be, I am a little lost again.
I appreciate the help and explanations to try to push me to get this on my
own, but at this point (especially after one week) this is when me being
given the answer with an explanation will help me
>> def ask_number(question, low, high, step = 1):
>> """Ask for a number within a range."""
>> response = None
>> while response not in range(low, high, step):
>> response = int(input(question))
>> return response
>
> With the only comment being that you don't really need the
> resp
On Fri, Jun 17, 2011 at 11:03 PM, Alan Gauld wrote:
>
> "Vincent Balmori" wrote
>
>> Here is my updated code. As simple as this may be, I am a little lost
>> again.
>
> I'm not sure why you are lost because that's pretty much it.
>
>> ... at this point (especially after one week) this is when me
"Vincent Balmori" wrote
Here is my updated code. As simple as this may be, I am a little
lost again.
I'm not sure why you are lost because that's pretty much it.
... at this point (especially after one week) this is when me being
given the answer with an explanation will help me much more,
gain at how Steven defined his function.
> What is different about his definition of n and your definition of
> step?
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> ______
"Vincent Balmori" wrote
"def spam(n=3):
"""Return n slices of yummy spam."""
return "spam "*n
This is my new code for a default step value based on your feedback
Steve:
def ask_number(question, low, high, step):
"""Ask for a number within a range."""
response = None
if step == N
Please try to reply to the previous letters instead of starting a new thread
each time. Thank you!
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
"def spam(n=3):
"""Return n slices of yummy spam."""
return "spam "*n
And here it is in use:
>>> spam(4)
'spam spam spam spam '
>>> spam() # just use the default
'spam spam spam '
Can you see what I did to set the default value for n? Read the function
definition line "def spam... " ca
Vincent Balmori wrote:
Okay, I think I understand it better for the quesiton:
"Improve the function ask_number() so that the function can be called with a step
value. Make the default value of step 1." Here is the improved function and the
human_move function that calls it later on. The thing
"From Steven D'Aprono:
* change the ask_number function
to accept a fourth argument;
* make it optional rather than
required;
* give it a sensible default
value;
* within the function, that value
must then be passed to range
"
Okay, I think I understand it better for the quesiton:
"Improve the fun
Vincent Balmori wrote:
The question to that code I am trying to solve is
"Improve the function ask_number() so that the function can be called with a
step value. Make the default value of step 1."
You need to be able to tell ask_number what step function you want to
use. So it isn't enou
"Vincent Balmori" wrote
I am still working on that one question in the absolute beginners
with the the
ask_number function and step value. Honestly, I still have no idea
what to do.
Take it stage by stage.
Define the function so that it takes a step parameter
with a default value of 1. Don;
I am copying and pasting your code here from the previous email:
def ask_number(question, low, high):
> """Ask for a number within a range."""
> response = None
> if response in range(low, high, 1):
> return response
> while response not in range(low, high):
> respon
The question to that code I am trying to solve is
"Improve the function ask_number() so that the function can be called with a
step value. Make the default value of step 1."
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscriptio
Without looking at your code,
What is it that you know that's wrong about it? Are you getting a return
value which you know is incorrect, is the program throwing error and you
aren't sure why? or do you just suspect it is wrong but you aren't sure?
When posing a question, it's helpful to know the
I am still working on that one question in the absolute beginners with the the
ask_number function and step value. Honestly, I still have no idea what to do.
This is one of my many attempts, but I know that it's wrong.
def ask_number(question, low, high):
"""Ask for a number within a range."
Vincent Balmori wrote:
I am stuck on a question for Absolute Beginner's. I googled this and there have
been others who have not understood the question and I am also not clear on the
question he is asking. This function is a part of a tic tac toe program."Improve
the function ask_number() so th
I am stuck on a question for Absolute Beginner's. I googled this and there have
been others who have not understood the question and I am also not clear on the
question he is asking. This function is a part of a tic tac toe
program."Improve
the function ask_number() so that the function can be
18 matches
Mail list logo