On 31/03/14 03:13, Scott Dunning wrote:
separate local variable, probably called I, which starts at
zero, and gets incremented each time.
The test in the while should be comparing them.
So, this is what I have now and it ‘works’
It doesn't work because they are all on the same line.
But also because it does NOT use iteration.
Your while loop is completely redundant. You could
remove the while and break lines and it would do
exactly the same.
def print_n(s,n):
while n < 10:
print s * n
break
You're other attempt where you increment n is much
closer to what is being asked for. The only difference
is you need to modify the while test to not use a hard coded
10 but use the parameter instead. Then use a separate
value to do the counting.
Incidentally, your assignment does not appear to require
a while loop, just iteration? If thats the case you could
use a for loop instead and it would actually be more
suitable. Have you covered for loops yet?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor