1.ใส่ชื่อตัวแปรไม่ตรงกัน เช่น
def setup():
string = 'thailand'
lasttring = 'and' <<<<<<<<<<<<< ผิดตรงนี้ไงครับ laststring สิ ไม่ใช่ lasttring อิอิ
assert my_endswith(string, laststring) == True
setup()
วิธีแก้คือ แก้ไขชื่อให้ตรงกัน โปรแกรมเราก็จะสามารถรันได้ตามปกติ
2.ลืมส่งค่ากลับ เช่น
def my_startswith(string, firststring):
result = False
i = 0
if (len(string) > len(firststring)):
while (i < len(firststring)):
if (string[i] == firststring[i]):
result = True
else:
result = False
i = i+1
โปรแกรมก็ไม่สามารถรู้ผลสิ วิธีแก้คือ ใส่ return result ไปซะ ดังนี้
def my_startswith(string, firststring):
result = False
i = 0
if (len(string) > len(firststring)):
while (i < len(firststring)):
if (string[i] == firststring[i]):
result = True
else:
result = False
i = i+1
return result <<<<<<<<<<<<<<<<<<<<<< นี้ไง ใส่มาแล้ว แค่นี้เราก็จะสามารถรันโปรแกรมได้ตามปกติ
3.ลืมอัพเดทค่า
def my_strip(string, strip):
wordwithoutstrip = ''
i = 0
while (i < len(string)):
if (i < len(strip)):
wordwithoutstrip = wordwithoutstrip + string[i]
return wordwithoutstrip แบบนี้เราก็จะรันโปรแกรมไม่ได้นะครับ วิธีแก้คือ
def my_strip(string, strip):
wordwithoutstrip = ''
i = 0
while (i < len(string)):
if (i < len(strip)):
wordwithoutstrip = wordwithoutstrip + string[i]
i = i+1 <<<<<<<<<<<<<<<<<<< ก็อัพเดทค่ามันซะสิ เราก็จะสามารถรันโปรแกรมได้ตามปกติ
return wordwithoutstrip
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
Link Video Presentation Resort Managemant System Project.
Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน ทองมณี 5801012620011 ลำดับภาพ: สุพิชชา ศรีศิริ...
-
- 1NF หรือ Fisrt Normal Form มีเงื่อนไขอยู่ว่า ต้องไม่มีคอลลัมน์ใดในตารางที่มีค่ามากกว่า 1 ค่า หรือที่เรียกว่า Atomic ซึ่งหมายถึง ข้อมูลที่...
-
เนื่องจากวันที่ 27 กุมภาพันธ์ ถึง 22 มีนาคม 2561 เป็นช่วงเวลาของการสอบกลางภาค ซึ่งทำให้ต้องแบ่งเวลาในการทำงานและอ่านหนังสือสอบอย่างหนัก จึง...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น