python - How to use hex numbers as a parameters -


my job program write function titled drawpolygonfilled() has 3 parameters (the number of sides polygon, color of edge, , color of fill). using value received parameter, draws regular polygon using “for”, colors edges , fills shape according parameter values. parameters colors must in hex notation.

i've written code draw polygons. working on trying fill polygons color, problem how use hex notation in parameters of function?

code:

from turtle import *  #use #dccdc def  drawpolygonfilled(n, filledcolor):     filledcolor = hex(filledcolor)     turtle()     begin_fill()     in range(n):         left(360/n)         forward(100)     color(filledcolor)     end_fill()     done() drawpolygonfilled(4,dccdc) #error 

you can specify color string this:

drawpolygonfilled(4, "#dccdc") 

note not need convert hex remove code.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -