def setup():
string = 'thailand'
endstring = 'and'
assert my_endswith(string, endstring) == True
def my_endswith(string, endstring):
result = False
i = 0
if (len(string) > len(endstring)):
while (i < len(endstring)):
if (string[i+(len(string)-len(endstring))] == endstring[i]):
result = True
else:
result = False
i = i+1
return result
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น