【发布时间】:2020-12-18 14:20:46
【问题描述】:
我做了一个简单的程序。它删除了 2 个字符串中的几个不同的子字符串。
喜欢Delete("hello","helloworld") -> "hello"。
然后,我收到以下错误:
IndexError: 从空列表中弹出
def Delete(s,t):
list_t=list(t)
list_s=list(s)
while list_t!=list_s:
list_t.pop()
#list_t.pop()
return "".join(list_t)
print(Delete("hello","helloworld"))
【问题讨论】:
标签: python algorithm index-error