> 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="https://1059722861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWAMRQLhtfzfy8yv80Se5%2Fuploads%2FeN9WLuI7kuQWgT7MhgoV%2Fexam04.png?alt=media&amp;token=d768158e-59e8-472b-ba0c-2b04be36d03d" alt=""><figcaption></figcaption></figure>
