vendredi 21 février 2014

Re: Function and turtle help topic




Scott W Dunning <(E-Mail Removed)> Wrote in message:
>
> On Feb 20, 2014, at 11:30 PM, Dave Angel <(E-Mail Removed)> wrote:
>
>> Look at turtle.begin_fill and turtle.end_fill
>>
>> That's after making sure your star is a closed shape.

>
>
>
> So, this is what I have so far and it “works” but, it fills in the star with black and as you can see below I am trying to fill it in with red. So I’m obviously messing up somewhere.
>
> def fillcolor(red):
> pencolor()
> begin_fill()
> star(500)
> end_fill()
>
> red = pencolor
> fillcolor(red)
>


You seem to have a fundamental misunderstanding of how variables
and function parameters work.

> def fillcolor(red):

The parameter should be something like color, not red.

> pencolor()

You need an argument to this function if you expect it to
change the color. I suggest color, the parameter we just
renamed.

> red = pencolor


That does nothing at all useful for you. I expect you really want
red = "red"


--
DaveA






Aucun commentaire:

Enregistrer un commentaire