我想知道如何从索引x到y删除多个值, 这是我目前正在努力的:
first_num = None
second_num = None
while True:
first_or_last = "first" if first_num is None else "last"
text = str("Enter the {} index number to start deleting: ").format(first_or_last)
remove_ftl_input = input(text)
if first_num is None or second_num is None:
if remove_ftl_input.isdigit():
if first_num is None:
first_num = int(remove_ftl_input)
elif first_num is not None and second_num is None:
second_num = int(remove_ftl_input)
if first_num is not None and second_num is not None:
for x in range(0, first_num-second_num):
try:
# note: every loop index shifts by -1 thats why first-num i assume?
found_items_list.pop(first_num)
except IndexError:
print(str(x) + " was out of reach.")
为什么不加入你想保留的范围呢
相关问题 更多 >
编程相关推荐