我已经编写了这段代码,但它并没有从列表中删除所有元素,而是只删除了 3 个项目。请检查我做错了什么
names = ["John","Marry","Scala","Micheal","Don"]
if names:
for name in names:
print(name)
print(f"Removing {name} from the list")
names.remove(name)
print("The list is empty")
繁星点点滴滴
呼啦一阵风
鸿蒙传说
相关分类