[Tutor] while loop
Alan Gauld
alan.gauld at btinternet.com
Mon Mar 31 11:01:02 CEST 2014
On 31/03/14 02:37, Scott Dunning wrote:
>> You're getting closer. Remember that the assignment shows your
>> function being called with 10, not zero. So you should have a
>> separate local variable, probably called I, which starts at
>> zero, and gets incremented each time.
> Without out a break or placing that 10 in there I can’t think
> of a way to have the while loop stop once it reaches (n).
Dave has explained in his first paragraph(above) how to do it.
n is a parameter in your function so the value is passed in
by the caller. You should not be using a literal 10 you should
be using n, since that's the required number of repeats.
Then you need to create a new local variable in your function
and let that variable count up until it equals whatever n is.
That's where the iteration comes in. And as you count
up, towards n, print s.
hth
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list