Count the letters · นับตัวอักษร
Count the letters
word is "banana". Use a for loop to count its letters into n. Do not use len.
A counter lives outside the loop (so it is not reset every turn) and grows inside it. That shape — set up, loop, use — comes back constantly.
นับตัวอักษร
word เป็น "banana" ใช้ for loop นับจำนวนอักษรลงใน n ห้ามใช้ len
ตัวนับ resides อยู่ นอก loop (ดังนั้นจึงไม่รีเซ็ตทุก รอบ) และเพิ่มขึ้น ภายใน loop รูปแบบนี้ — ตั้งค่า, loop, ใช้ — กลับมาซ้ำๆ เสมอ
word is "banana". Use a for loop to count its letters into n. Do not use len. · word เป็น "banana" ใช้ for loop นับจำนวนอักษรลงใน n ห้ามใช้ len
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่