[Tutor] while loop
Scott W Dunning
scott.w.d at cox.net
Sat Mar 29 06:18:52 CET 2014
On Mar 28, 2014, at 9:54 PM, Scott W Dunning <scott.w.d at cox.net> wrote:
> Hello, I’m working on some practice exercises from my homework and I’m having some issues figuring out what is wanted.
>
> We’re working with the while loop and this is what the question states;
>
> Write a function print_n that prints a string n times using iteration.
>
> """Print the string `s`, `n` times.
>
>
> This is also in the exercises and I’m not sure what it means and why it’s there.
>
> assert isinstance(s, str)
> assert isinstance(n, int)
>
>
> Any help is greatly appreciated!
>
> Scott
This is what I have so far but I’m not really sure it’s what the excersise is asking for?
n = 5
def print_n(s, n):
while n > 0:
print s * n
print_n("hello", 10)
More information about the Tutor
mailing list