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")只需在 for 循环中按名称 [:] 分配全名列表JohnRemoving John from the listMarryRemoving Marry from the listScalaRemoving Scala from the listMichealRemoving Micheal from the listDonRemoving Don from the listThe list is empty