วันพุธที่ 30 กันยายน พ.ศ. 2558

Lab05 : String Replace

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def setup():
    print(my_replace("Thailand","land","thai"))
def my_replace(t,s,r):
    i=0
    text=""
    while i<len(t):
        if check(t,s,i):
            text+=r
            i+=len(s)
        elif i<len(t):
            text+=t[i]
            i+=1
    return text
def check(t,s,index):
    i=0
    count=0
    while i<len(s) and index+i<len(t):
        if t[index+i]==s[i]:
            count+=1
            if count==len(s):
                return True
        i+=1
    return False
setup()
http://pastebin.com/k5kt2p7x

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

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

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...