The script linked below draws the Sierpinski Triangle. Modify it (or write your own code from scratch - I don't care) so that it draws Sierpinski's Carpet. (I'll let you Google that.) Note that it makes use of Python's Turtle Module. So if you're at replit, you should create a Python (with Turtle) repl. The documentation for the Turtle Module resides at python.org.
Requirements:
Iterate through the first six carpets as my code iterates through the first six triangles.
As you work through the recursive levels of a given carpet, change the pen color.
Extra Credit:
Do Sierpinski's Pentagon.
Extra Extra Credit:
Write me a higher-level function named sierPoly (short for "Sierpinski's Polygon") that has an additional parameter n for number of sides and will draw, for any n, the Sierpinski object with n sides. So for n = 5, it will draw the Sierpinski Pentagon; and for n = 6, it will draw the Sierpinski Hexagon (again Google). Etc.
When I hit run, your program should draw the Sierpinski Carpet for n = 1. It should then pause for a second, clear the screen and the draw the Sierpinski Carpet for n = 2. It should continue on in this way until n = 6. The n = 6 version should be left on the screen once the animation is complete.