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

my_strip

def setup():
   string = 'thailand    '
   strip = '        '
   print("world is", my_strip(string, strip))
   assert my_strip(string, strip) == 'thailand'

def my_strip(string, strip):
   nostrip = ''
   i = 0
   while (i < len(string)):
      if (i < len(strip)):
         nostrip = nostrip + string[i]
      i = i+1
   return nostrip

setup()

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

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