Scott Dunning <swdunn...@me.com> Wrote in message: > > On Mar 31, 2014, at 5:15 AM, Dave Angel <da...@davea.name> wrote: >> >> Do you know how to define and initialize a second local variable? >> Create one called i, with a value zero. >> >> You test expression will not have a literal, but compare the two >> locals. And the statement that increments will change i, not >> n. > > So like this? > def print_n(s,n): > i = 0 > while i < n: > print s, > i += 1 > > print_n('a',3) > > So this is basically making i bigger by +1 every time the while loop passes > until it passes n, then it becomes false right? > > Also, with this exercise itâs using a doctest so I donât actually 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? >
The trailing comma on the print statement is suppressing the newline that's printed by default. If you want them on separate lines, get rid of the comma. -- DaveA
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor