這是我的代碼。我只是用「%20」替換字符串中的所有空格我的python代碼中的迭代不會到最大範圍
最後一次迭代後,當i = 18和len(var)的值仍然是25時,代碼正在退出for循環。請幫忙。
var1 = 'hello world ho are '
var=list(var1)
print(len(var1))
print(var1[5])
n =len(var)
for i in range(0, len(var)):
print(i)
print("length before", len(var))
if(var[i] == " "):
var[i+3:] = var[i+1:]
var[i] = "%"
var[i+1] = "2"
var[i+2] = "0"
print("length after",len(var))
print("value of i", i)
print(len(var))
print((var))