ตัวอย่างโค้ดภาษา Python ในการรับข้อความโดยระบุจำนวนข้อความได้ตามต้องการ จากนั้นนำข้อความที่ได้มาหาความยาวของแต่ละข้อความ
ตัวอย่างโค้ด Python
'''
Author : Computer For Education
Author URI: https://www.computerforedu.com
Facebook : https://www.facebook.com/computerforedu
'''
size = int(input("ป้อนจำนวนข้อความที่ต้องการ : "))
text_list = []
print("\n======== INPUT ========")
for i in range(size):
text = input(f"ป้อนข้อความที่ {i+1}: ")
text_list.append(text)
print("\n======== OUTPUT ========")
for i, s in enumerate(text_list):
print(f"{i+1}. {s} = {len(s)}")
แสดงผล

