วันอาทิตย์ที่ 4 ตุลาคม พ.ศ. 2558

[LAB5] my_endswith()

def my_endswith():
   my_endswith = 'Thailand'
   check = False
   word = 'and'
   first_index = len(word)-1
   second_index = len(my_endswith)-1
   count = 0
   k = 0
   if(len(my_endswith) >= len(word)):
      while(k < len(word)):
         if(word[first_index] == my_endswith[second_index]):
            count = count +1
         first_index = first_index - 1
         second_index = second_index - 1
         k = k + 1
         if(count != 0 and count%len(word) == 0):
            check = True
   return check

print(my_endswith())

ไม่มีความคิดเห็น:

แสดงความคิดเห็น