result = ""
i = 0
while( i < len(string) ):
if(check(getout,string,i)):
result = result + replace
i = i +len(replace)
else:
result = result + string[i]
i = i +1
return result
def check(getout,string,i):
count =1
while(count<len(getout)):
if(getout[count]!=string[i]):
return False
else:
count = count+1
i = i+1
return True
assert (my_replace("ThaiLand","Land","Joke")=="ThaiJoke")
print (my_replace("ThaiLand","Land","Joke"))
ThaiJoke
ไม่มีความคิดเห็น:
แสดงความคิดเห็น