[Tutor] Function help

Scott W Dunning swdunning at cox.net
Mon Feb 24 03:15:05 CET 2014


On Feb 23, 2014, at 2:26 AM, Peter Otten <__peter__ at web.de> wrote:
> If you want to make rows with more or less stars, or stars in other colors 
> you could add parameters:
> 
> def star_row(numstars, starcolor):
>    for i in range(numstars):
>        fillstar(starcolor)
>        space(25)
> 
> Your code will then become
> 
> star_row(6, red)
> row(25)
> star_row(5, red)
> row(25)
> 
I have a question with the above loop function.  Why couldn’t row(25) be added into the function so that wouldn’t have to placed in between every star_row()?
> 
> which still shows a repetetive pattern and thus you can simplify it with 
> another loop. You should be able to find a way to write that loop with two
> star_row() calls on a single iteration, but can you do it with a single call 
> too?
Not sure I understand what you mean in the above paragraph?  




More information about the Tutor mailing list