new = ''
i = 0
while (i < len(string)):
if (i < len(replace)):
new = new + replace[i]
elif (i >= len(replace)):
new = new + string[i]
i = i+1
return new
def setup():
string = 'thailand'
replace = 'blue'
print("Old world is", string, "and New world is", my_replace(string, replace))
assert my_replace(string, replace) == 'blueland'
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น