Skip to content
Sign upLog in
← Back to Community

Why isn't my code working

Profile icon
SreePaladugu

I am confused. I am pretty sure, that the code is right, I don't understand why it isn't working. What I am trying to do is create a star that is filled in. Can someone help me find my mistake?

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Profile icon
SreePaladugu
Comments
hotnewtop
Profile icon
Bookie0

you made a function called mystar, but you didnt call it.

just do mystar(size, filled) and i think you have to replace size with a number and filled with a color i think.

hope this helps! =)

Profile icon
SreePaladugu

@Bookie0
Didn't I already do that? def mystar(size,filled), it's on line 4

Profile icon
Bookie0

no you defined the function.
now you have to call it, like execute it/

@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
wait so like this, but when I run it, it's not working, its says bad input on line 5, what am I doing wrong?:

t = turtle.Turtle() def mystar(size, filled): mystar(size,filled): if filled == True: t.begin_fill() for x in range(1, 19): t.forward(size) if x % 2 == 0: t.left(175) else: t.left(225) if filled == True: t.end_fill()
Profile icon
Bookie0

no, put def mystar(size, filled) afterwards, out of the function loop. like the last line, but not indented.

then you replace size with a number and filled with a color i think

@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
Ok so like this, but it is still not working.

t = turtle.Turtle() def mystar(size, filled): if filled == True: t.begin_fill() for x in range(1, 19): t.forward(20) if x % 2 == 0: t.left(175) else: t.left(225) if filled == True: t.end_fill() mystar(size,filled): mystar(20,'yellow')
Profile icon
Bookie0

no take the ```at the end off.
also delete the second to last line (mystar(size,filled)

@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
Ok so like this, it still isn't working, it is like a line...

def mystar(size, filled): if filled == True: t.begin_fill() for x in range(1, 19): t.forward(20) if x % 2 == 0: t.left(175) else: t.left(225) if filled == True: t.end_fill() mystar(20, 'green')
Profile icon
Bookie0

@SreePaladugu

put quotation marks around yellow
Screen Shot 2020-06-30 at 2.38.00 PM

Profile icon
SreePaladugu

@Bookie0
it produces a line instead of a star...

Profile icon
Bookie0

hum maybe thats just your math. i found this, maybe it can help: https://stackoverflow.com/questions/26356543/turtle-graphics-draw-a-star


@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
got it thanks!

Profile icon
Bookie0

sure,

please mark this answer as correct if it helped you =)

@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
Got it okay!

Profile icon
Bookie0

cool and thanks for selecting my answer =)

@SreePaladugu

Profile icon
SreePaladugu

@Bookie0
No problem 😁