[Tutor] while loop

Scott Dunning swdunning at me.com
Mon Mar 31 04:13:00 CEST 2014


On Mar 30, 2014, at 4:29 AM, Dave Angel <davea at davea.name> 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. 
> 
> The test in the while should be comparing them.
> 
So, this is what I have now and it ‘works’ but, instead of printing (s) on seperate lines they’re all on the same line?

def print_n(s,n):
    while n < 10:
        print s * n
        break
    assert isinstance(s, str)
    assert isinstance(n, int)
        



More information about the Tutor mailing list