> For the complete documentation index, see [llms.txt](https://krootee.gitbook.io/python-turtle/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krootee.gitbook.io/python-turtle/1.example01-10/04..md).

# 04.วาดรูปหกเหลียม

{% code title="" overflow="wrap" lineNumbers="true" fullWidth="true" %}

```python
import turtle  # นำเข้าไลบรารี turtle

t = turtle.Turtle()  # สร้างวัตถุ turtle ใหม่
t.shape('turtle')  # กำหนดรูปร่างของ turtle เป็น 'turtle'

for i in range(6):  # วาดรูปหกเหลี่ยม ทำซ้ำ 6 ครั้ง
    t.forward(100)  # เคลื่อนที่ไปข้างหน้า 100 หน่วย
    t.left(60)  # หันซ้าย 60 องศา

t.hideturtle()  # ซ่อน turtle เมื่อวาดเสร็จ
turtle.done()  # รอให้ผู้ใช้ปิดหน้าต่าง
```

{% endcode %}

<figure><img src="/files/tvJyLFjp341cFtfaVYa5" alt=""><figcaption></figcaption></figure>
