# 输入一个数据,删除一个列表中的所有指定元素# 给定的列表数据data = [1,2,3,4,5,6,7,8,9,0,5,4,3,5,"b","a","c","f","d","b","a","c",] print("打印删除前的列表元素!")print(data) # 用户输入needDeleteElement = input("请输入需要删除的列表元素:") # 如果用户输入的是数字就进行数据转换if needDeleteElement.isdigit(): needDeleteElement = int(needDeleteElement) # while删除列表元素while needDeleteElement in data: data.remove(needDeleteElement) print("打印删除后的列表元素!")print(data)
原文地址:https://www.cnblogs.com/yunlongaimeng/p/8728652.html
时间: 2024-11-06 22:46:16