[Tutor] while loop

Alan Gauld alan.gauld at btinternet.com
Tue Apr 1 12:19:13 CEST 2014


On 01/04/14 00:22, Scott Dunning wrote:

> def print_n(s,n):
>      i = 0
>      while i < n:
>          print s,
>          i += 1
>
> print_n('a',3)
>
> Also, with this exercise it’s using a doctest so I don’t actually call the function

I have no idea what you mean buy this?
There is no doctest above and you do call the function...

> so I can’t figure out a way to make the string’s print on
 > separate lines without changing the doctest code?

You don't have any doctest code and the printing on one line
is a result of the comma in the print statement.


-- 
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